0

I have been had a little problems by customizing luma's default footer, for that, I decided to delete it and in its place add a new block that i created in the admin.

I deleted the footer (not entirely, I left the copyright bar) via XML by doing

<referenceContainer name="footer" remove="true"/>

and created its substitute via admin, in where i added it to my home.

I want the block to be in all the pages as my old footer was. What can i do?

2
  • Are u using any custom theme? Commented Aug 30, 2018 at 18:22
  • Is your issue resolved, please mark the answer you used as accepted if so. Commented Aug 30, 2018 at 20:19

5 Answers 5

2

I thing you don't need to delete footer file. Just override footer file app/design/frontend/Vendor/ThemeName/Magento_Theme/layout/default.xml or in your luma theme 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>

And call your static block in ../templates/html/footer.phtml file.

echo $this->getLayout()
          ->createBlock('Magento\Cms\Block\Block')
          ->setBlockId('your_block_identifier')
          ->toHtml();

Now your block content displayed in all pages

Also using this method you can do your other customization like calling newsletter, get default footer link and custom php codes as per your requirements.

0

You can add your cms block to all pages in footer section by adding following in your app/design/frontend/[Vendor]/[Theme]/Magento_Theme/layout/default.xml

<referenceContainer name="footer"> 
    <block class="Magento\Cms\Block\Block" name="block_identifier"> 
        <arguments> 
            <argument name="block_id" xsi:type="string">block_identifier</argument> 
        </arguments> 
    </block> 
</referenceContainer>

Where you have to replace block_identifier with your block identifier.

If you already have a footer reference container, add the code inside it.

0

Create a default.xml file in : app/code/[Vendor]/[ModuleName]/view/frontend/layout/default.xml then add inside :

<?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>
    <block class="Magento\Theme\Block\Html\Footer" name="footer_wrapper" template="Magento_Theme::footer/footer.phtml" before="before.body.end">
        <block class="Magento\Cms\Block\Block" name="footer-custom">
            <arguments>
                <argument name="block_id" xsi:type="string">FOOTER_ID</argument>
            </arguments>
        </block>
    </block>
</body>

Where FOOTER_ID is your block identifier in admin.

Don't forget to flush the cache.

0

You can call your block through XML by putting below code in your theme default.xml within body tag :

<referenceContainer name="footer">
    <block class="Magento\Cms\Block\Block" name="footer-block">
        <arguments>
            <argument name="block_id" xsi:type="string">block_identifier</argument>
        </arguments>
    </block>
</referenceContainer>
0

If you want to have the original footer as a custom one, you have to add this :

  1. app/design/frontend/{Vendor}/{Theme}/Magento_Theme/layout/default.xml

    <referenceContainer name="footer-container">
        <container name="footer-custom" as="footer.cust" label="New Footer" htmlTag="div" htmlClass="footer footer-new content">
            <block class="Magento\Store\Block\Switcher" name="store_switcher" as="store_switcher" template="Magento_Store::switch/stores.phtml"/>
            <block class="Magento\Framework\View\Element\Html\Links" name="footer_links">
                <arguments>
                    <argument name="css_class" xsi:type="string">footer links</argument>
                </arguments>
            </block>
            <block class="Magento\Theme\Block\Html\Footer" name="copyright" template="Magento_Theme::html/copyright.phtml"/>
            <block class="Magento\Framework\View\Element\Template" name="report.bugs" template="Magento_Theme::html/bugreport.phtml" />
            <block class="Magento\Framework\View\Element\Template" name="extra-block1" template="Magento_Theme::html/footer_extra1.phtml"/>
        </container>
    </referenceContainer>
    
  2. app/design/frontend/{Vendor}/{Theme}/Magento_Theme/templates/html/footer_extra1.phtml

    Some content here

    The step 2 is just if you want to add some new block in that custom footer, this block is declared too in the last xml block.

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.