Magento 2 – How to Override Footer Template in Custom Theme

cemagento2templatetheme

I'm trying to override the footer template from a custom theme:

vendor/magento/module-theme/view/frontend/templates/html/footer.phtml

Copying the file in my theme folder:

app/design/frontend/<Vendor>/<ThemeName>/Magento_Theme/templates/html/footer.phtml

Then I removed all the content leaving only this:

<div class="footer-container">
</div>

But still I see the whole footer from the Magento's module.

Where am I wrong?

Best Answer

The configuration of the footer can be seen in this file: vendor/magento/module-theme/view/frontend/layout/default.xml

I was able to modify the footer declaration by creating my own default.xml file at app/design/frontend/<Vendor>/<ThemeName>/Magento_Theme/layout/default.xml with this content:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="footer-container">
            <block class="Magento\Theme\Block\Html\Footer" name="footer" template="html/footer.phtml"/>
        </referenceContainer>
    </body>
</page>

Now my custom footer.phtml file is called instead of the containers/blocks defined in the original default.xml.

Related Topic