0

I'm trying to add a simple div around the copyright & bug report links in the footer. I can achieve this by doing this:

<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="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>
      <container name="copyright-bug" htmlTag="div" htmlClass="bottom-links">
        <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" ifconfig="design/footer/report_bugs"/>
      </container>
  </container>
</referenceContainer>

This adds a div called bottom-links around the copyright and bug reports links but it removes all other elements such as footer links, header links, basket link. What am I doing wrong?

0

In a separate layout file in your Magento theme or in a layout file that is within a custom module, you may use a reference to the container "footer".

Like below:

  <referenceContainer name="footer">
      <container name="copyright-bug" htmlTag="div" htmlClass="bottom-links">
        <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" ifconfig="design/footer/report_bugs"/>
  </container>
</referenceContainer>

To explain this answer, the footer_links block happens to be defined in vendor/magento/module-theme/view/frontend/layout/default.xml and you will see, the block is a direct child to the container footer. Therefore you want to take its reference like above whereas using container node would redefine the container and therefore overwrite its previous chidlren

| improve this answer | |

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.