5

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?

7

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.

  • This is the best answer I've found if you want to create a footer from scratch. I haven't found how to copy the original phtml to use as a base to apply changes to it. – StR Nov 27 '18 at 14:51
  • 1
    @StR That's the catch. There is no original phtml. See, the footer has a layout which divides it into columns. Now the stuff you see in your default footer, are injected in xml layouts files across the theme. basically, any extension could add or modify the content of your footer. Or at least that what I understood so far. – Mohammed Joraid Feb 20 at 22:41
6

I found out what was my problem.

Firstly I enabled the template path hints mode as described here: http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/themes/debug-theme.html

Thanks to path hints, I understood that the theme was not using the footer.phtml file, but was using bugreport.phtml and copyright.phtml both from the magento-theme module.

So I created these two templates:

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

And now I'm able to override them from my custom theme.

  • Non of the files you said worked for me, I copied bugreport.phtml, copyright.phtml, absolute_footer.phtml, to use as a base, and non of them overwrite the <footer> block. The bugreport never renders at all. both copyright and absolute_footer are under the <footer> node. I'm still trying to find the right template. – StR Nov 27 '18 at 14:53

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.