1

I'm trying to load a custom phtml for the frontpage. I found this topic and it got me off to the right track.

I created my /app/design/frontend/theme/skin/Magento_Theme/layout/cms_index_index.xml and added this code;

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
   <referenceContainer name="page.top">
     <block class="Magento\Framework\View\Element\Template" name="engels_home" template="html/engels_home.phtml">
        <arguments>
            <argument name="section" xsi:type="string">homepage</argument>
            <argument name="position" xsi:type="number">0</argument>
        </arguments>
     </block>
  </referenceContainer>         
</page>

So I figured I have to create the .phtml file in app/design/frontend/theme/skin/Magento_Theme/templates/html/engels_home.phtml based on the logic that a layout file in Magento_Theme would point to a template file in that same structure. I guess I was wrong here, because I saw that other references where made to the Magento_Store folder. So I added the engels_home.phtml to that folder. And then to the rest. Then I spread it out all over the filesystem just to see what sticks.

Nothing did, my system.log keeps saying the same thing:

main.CRITICAL: Invalid template file: 'html/engels_home.phtml' in module: '' block's name: 'engels_home' [] []

no matter where I put the file.

Does anyone know where to put it, or better yet, understand why all of this above wouldn't work? It's driving me nuts at this point.

PS. I'm sorry to knowingly create a "duplicate" post, but this is the downside of the reputation system. I can ask questions, but not (yet) comment on others..

2

If you have already not created a custom theme then create by following this post :

And then Create xml file name with /app/design/frontend/Vendor/theme/Magento_Theme/layout/cms_index_index.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
   <referenceContainer name="page.top">
     <block class="Magento\Framework\View\Element\Template" name="startphoto" template="Magento_Theme::html/yourtemplate.phtml">
        <arguments>
            <argument name="section" xsi:type="string">homepage</argument>
            <argument name="position" xsi:type="number">0</argument>
        </arguments>
     </block>
  </referenceContainer>         
</page>

Clear the cache.

Done!

  • So it was the Magento_Theme::html/yourtemplate.phtml part that saved the day. Now I gotta ask; what kind of markup is this? Why the double :: instead of just a path like Magento_Theme/html/template.phtml? – Alex Timmer Apr 15 '16 at 7:01

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.