0

I created a new page layout, but I noticed that it does not get loaded last and it gets overridden from other layouts.

Is there a way to change the load order so that my custom page layout gets loaded last?

Example:

I have this simple layout where I create a new block which just shows the text foobar123. I move it after the header.container.

THEME\layout\catalog_product_view.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>

        <block class="Magento\Framework\View\Element\Template"
               name="test_foobar"
               template="Hausfux_Base::test.phtml" />

        <move element="test_foobar" destination="page.wrapper" after="header.container"/>
    </body>
</page>

THEME\Company_Base\templates\test.phtml

foobar123

Now I create a new page layout and try to move it after the footer only for this page layout.

THEME\Magento_Theme\layouts.xml

<?xml version="1.0" encoding="UTF-8"?>
<page_layouts xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/PageLayout/etc/layouts.xsd">
    <layout id="hf-grouped-product-big-1col">
        <label translate="true">Hf Grouped Product (Big) -- 1 Col</label>
    </layout>
</page_layouts>

THEME\Magento_Theme\page_layout\hf-grouped-product-big-1col.xml

<?xml version="1.0"?>
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
    <update handle="1column"/>

    <move element="test_foobar" destination="page.wrapper" after="footer-container"/>
</layout>

Now I select my new custom page layout Hf Grouped Product (Big) -- 1 Col on a product and load it, then the text "foobar123" is showing, but still after the header, because my custom page layout is getting loaded before catalog_product_view.xml.

How can I make my custom page layout always get loaded last?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.