2

I'm trying to remove the cms content from the homepage, whilst keeping all the meta stuff from the CMS panel.

So initially i was using:

<referenceBlock name="cms_page" remove="true" />

which removes the cms content but it also removes all the meta stuff as well. I can remove the Page header ok with:

<referenceBlock name="page.main.title" remove="true" />

but this still keeps the cms content.

In a nut shell i have several .phtml blocks on this page which i'm including in cms_index_index.xml like so:

<referenceContainer name="content">
    <block class="Magento\Framework\View\Element\Template" name="block1" template="Magento_Cms::home/block1.phtml" />
    <block class="Magento\Framework\View\Element\Template" name="block2" template="Magento_Cms::home/block2.phtml" />
    <block class="Magento\Framework\View\Element\Template" name="block3" template="Magento_Cms::home/block3.phtml" />
    <block class="Magento\Framework\View\Element\Template" name="block4" template="Magento_Cms::home/block4.phtml" />
</referenceContainer>

i know i could add this as the 'cms content' but this isn't really an option as the people who would be updating the meta shouldnt be able to edit the cms content.

basically i just want a thing similar to this:

or the ability to remove 'cms_page' and then re-add the meta options after.

3

So my solution to keep the meta content working from the CMS page but removing the cms content from the page goes like this:

<!-- remove page title -->
<referenceBlock name="page.main.title" display="false"/>
<!-- remove cms content block (but keep the cms part so meta data can be updated) -->
<referenceBlock name="content" display="false"/>

<!-- add new homepage content -->
<referenceContainer name="main">
    <container name="home.content" htmlTag="div" before="-">
        <block class="Magento\Framework\View\Element\Template" name="block1" template="Magento_Cms::home/block1.phtml" />
        <block class="Magento\Framework\View\Element\Template" name="block2" template="Magento_Cms::home/block2.phtml" />
        <block class="Magento\Framework\View\Element\Template" name="block3" template="Magento_Cms::home/block3.phtml" />
        <block class="Magento\Framework\View\Element\Template" name="block4" template="Magento_Cms::home/block4.phtml" />
    </container>
</referenceContainer>
0

Beware: removing the content with

<referenceBlock name="content" display="false"/>

can cause the following error:

customer-data.js:90 Uncaught TypeError: Cannot read property 'sectionLoadUrl' of undefined
at Object.getFromServer (customer-data.js:90)
at Object.reload (customer-data.js:336)
at UiClass.initialize (minicart.js:108)
at UiClass.initialize (wrapper.js:109)
at new UiClass (class.js:49)
at Object.initComponent (layout.js:137)
at fire (jquery.js:3232)
at Object.fireWith [as resolveWith] (jquery.js:3362)
at Object.deferred.<computed> (jquery.js:3461)
at fire (jquery.js:3232)
0

<referenceBlock name="cms_page" remove="true"/> now works in 2.3 without removing meta/script stuff.

Your Answer

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

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