0

I have made a theme, lets call it Mytheme/custom. I want to add a .phtml file to the sidebar. How do I do that?

I have already made this but it doesn't work:

Mytheme/custom/Magento_Catalog/layout/default.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="sidebar.additional">
            <block class="Magento\Framework\View\Element\Template" name="seotext_sidebar"
                   template="Mytheme_Custom::product/sidebar/seotext.phtml">
            </block>
        </referenceContainer>
    </body>
</page>

Mytheme/custom/Magento_Catalog/templates/product/sidebar/seotext.phtml

<h1>test</h1>

Also I want the current category information be available to seotext.phtml should I change Magento\Framework\View\Element\Template to something else?

2

Update xml file as follows.

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="sidebar.additional">
            <block class="Magento\Framework\View\Element\Template" name="seotext_sidebar" template="Magento_Catalog::product/sidebar/seotext.phtml">
            </block>
        </referenceContainer>
    </body>
</page>

Note: Correction in template="Mytheme_Custom::product/sidebar/seotext.phtml"

  • It doesn't work for me yet, but I need to test a couple of things though. Will accept it if it works. Might be the "Infortis" theme interfer with the code. – Cudos Apr 19 '17 at 13:41

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.