0

I want to have a phtml file load only on the category pages . So In a specific category in the design tab I put the below code in the design layout xml textarea.

<referenceContainer name="page.bottom.container">
<container name="categoryugc" htmlTag="div" htmlClass="ugc">
    <block class="category-ugc" name="bottom.ugc.div" template="category-ugc.phtml"/>
</container>

I then created the category-ugc.phtml file in

app/design/frontend/Smartwave/porto_child/Smartwave_Porto/templates/html/

I cleared cache and refreshed the page but it still doesnt show the needed phtml page?

1 Answer 1

1

If you want to add your phtml in all category pages.

Theme :

app/design/frontend/Smartwave/porto_child/Magento_Theme/layout/catalog_category_view.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="page.bottom.container">
            <container name="categoryugc" htmlTag="div" htmlClass="ugc">
                <block class="Vendor\Name\Block\Block" name="bottom.ugc.div" template="category-ugc.phtml"/>
            </container>
        </referenceContainer>        
    </body>
</page>

Module :

If you have a module for that, add it on it instead:

app/code/Vendor/Name/view/frontend/layout/catalog_category_view.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="page.bottom.container">
            <container name="categoryugc" htmlTag="div" htmlClass="ugc">
                <block class="Vendor\Name\Block\Block" name="bottom.ugc.div" template="Vendor_Name::category-ugc.phtml"/>
            </container>
        </referenceContainer>        
    </body>
</page>
1
  • You're welcome, good luck !
    – PЯINCƎ
    Commented Apr 25, 2018 at 19:48

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.