2

I tried to add some static blocks in the footer: <referenceContainer name="footer-container" from xml and it's not working.

But if I add in: <referenceContainer name="before.body.end"> after name="absolute_footer" it's working.

This is my code:

<referenceContainer name="footer-container">
    <container name="footer" as="footer" label="Page Footer" htmlTag="div" htmlClass="footer content">
        <block class="Magento\Store\Block\Switcher" name="store_switcher" as="store_switcher" template="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\Cms\Block\Block" name="basket_rent">
            <arguments>
                <argument name="block_id" xsi:type="string">basket_rent</argument>
            </arguments>
        </block>
        <block class="Magento\Theme\Block\Html\Footer" name="copyright" template="html/copyright.phtml"/>
        <block class="Magento\Framework\View\Element\Template" name="report.bugs" template="Magento_Theme::html/bugreport.phtml" />
    </container>
</referenceContainer>
<referenceContainer name="before.body.end">
    <block class="Magento\Theme\Block\Html\Footer" name="absolute_footer" template="html/absolute_footer.phtml" />
    <block class="Magento\Cms\Block\Block" name="basket_rent">
        <arguments>
            <argument name="block_id" xsi:type="string">basket_rent</argument>
        </arguments>
    </block>
</referenceContainer>

My block's identifier is: basket_rent.

Please Help and thank you.

1

You can try to extend the default.xml file in your theme, add in the a reference for the footer container and the script for the cms block.

Like this:

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

You can also try to add after="-" in the cms script, it force to place this block at the end of the container.

Like this:

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

PS: if you edit the core files of M2 maybe you have to clean the cache or upgrade the M2 setup. It's better to extend the file instead.

| improve this answer | |
0

If you want add static block in footer, use below reference for it.

<referenceContainer name="footer">
    <block class="Magento\Store\Block\Switcher" name="store_switcher" as="store_switcher" template="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\Cms\Block\Block" name="basket_rent">
        <arguments>
            <argument name="block_id" xsi:type="string">basket_rent</argument>
        </arguments>
    </block>
    <block class="Magento\Theme\Block\Html\Footer" name="copyright" template="html/copyright.phtml"/>
    <block class="Magento\Framework\View\Element\Template" name="report.bugs" template="Magento_Theme::html/bugreport.phtml" />
</referenceContainer>
| improve this answer | |
  • Will that work also if he will added it the same static block in the absolute_footer? Cuz from his post i see that he wants to add 2 static blocks in 2 different places – Attila Naghi Nov 18 '16 at 13:37

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.