0

I have added multiple referenceBlocks in the default.xml file for the Magento theme. Which I thought would work but it appears it will only ever show which ever is last in the XML file. (i.e. if I swap custom.home to be before customer.header then the header element would show, and vise versa).

Note the order only makes a difference in default.xml not home.xml (the layout file). Can I have multiple reference blocks or am I missing something?

default.xml

    <!-- Removed blocks -->
    <referenceBlock name="catalog.compare.sidebar" remove="true" />
    <referenceBlock name="top.search" remove="true" />
    <referenceBlock name="top.links" remove="true" />
    <referenceBlock name="header.container" remove="true" />
    <referenceBlock name="navigation.sections" remove="true" />
    <referenceBlock name="footer" remove="true" />

    <!-- Add custom blocks -->
    <referenceBlock name="custom.header">
        <container name="globalheader" htmlTag="div" htmlClass="globalheader">
            <block class="Magento\Framework\View\Element\Template" name="row" template="Magento_Theme::html/globalheader.phtml">
                </block>
        </container>
    </referenceBlock>

    <referenceBlock name="custom.home">
        <container name="homehtml" htmlTag="div" htmlClass="htmlHome">
            <block class="Magento\Framework\View\Element\Template" name="row" template="Magento_Theme::html/home.phtml">
            </block>
        </container>
    </referenceBlock>

Home.xml

    <referenceContainer name="main.content" remove="true" />
    <referenceContainer name="content" remove="true" />

    <referenceContainer name="page.wrapper">
        <container name="custom.header" as="custom_header_container" label="Page Header Container" before="main.content"/>
        <container name="custom.home" as="custom_home_container" label="Route for Static HTML Page"  />
    </referenceContainer>
</layout>
2
  • Have you applied below solution ? Commented Oct 6, 2016 at 4:48
  • @SHPatel It was at the end of the day so have only just done it, it worked so thanks. Stupid error though, guess I was tired!
    – tim.baker
    Commented Oct 6, 2016 at 7:28

1 Answer 1

1

You have used same block reference name as name="row"

change block name like name="row" and name="rowtest" something like this.

Let me know if not working this solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.