1

I'm trying to include a new template block in a CMS page in the admin via layout updates. Here is the xml:

<block class="Magento\Catalog\Block\Product\View\Description" name="homepage.carousel" template="homepage/carousel.phtml" before="-" />

The carousel template has been added in [theme-folder]/Magento_Theme/templates/homepage/carousel.phtml. Then I run:

  1. bin/magento cache:flush
  2. bin/magento setup:static-content:deploy

No luck, so then I moved the template to [theme-folder]/Magento_Cms/templates/homepage/carousel.phtml. I re-run the above commands but still no luck. Then I changed the CMS page "New Theme" and set it to my custom theme and re-run the above commands and still no luck. Any suggestions?

  • The error was that I forgot to wrap the XML inside a <referenceContainer name="content">. So the fix to this issue is to add the xml update inside <referenceContainer name="content"></referenceContainer> – AdrianS Mar 2 '17 at 23:44
  • You should post your comment as an answer to your own question, and accept it. This helps others who are having the same issue. – Danny Nimmo Mar 3 '17 at 0:52
  • In template="homepage/carousel.phtml" can try with template="Magento_Theme::homepage/carousel.phtml" ? – Jackson Mar 3 '17 at 9:10
0

The error was that I forgot to wrap the XML inside a <referenceContainer name="content">. So the XML should look like this:

<referenceContainer name="content">
    <block class="Magento\Catalog\Block\Product\View\Description" name="homepage.carousel" template="Magento_Theme::homepage/carousel.phtml" before="-" />
</referenceContainer>

And the other thing is that you should add the magento module inside the template src E.g:

<block class="Magento\Catalog\Block\Product\View\Description" name="homepage.carousel" template="Magento_Theme::homepage/carousel.phtml" before="-" />   

Kudos for this last part to Ankit Shah

| improve this answer | |

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.