0

Just getting to grips with Magento 2.. I have created and applied a child theme of Luma that seems to work fine. It pulls in my CSS files and things like that. But I would like to add some custom blocks to the footer.

Here are the contents of my default.xml which is in mytheme/Magento_Theme/layout/default.xml

As you can see I've tried to create a new block called footer_social, I have then created a .phtml file which sits in mtheme/Magento_Theme/html/footer_social.phtml and added a little bit of text to it to test but nothing changes. Guessing I am missing something? Any help appreciated.

    <?xml version="1.0"?>
<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="header.panel">
            <block class="Magento\Framework\View\Element\Html\Links" name="header.links">
                <arguments>
                    <argument name="css_class" xsi:type="string">header links</argument>
                </arguments>
            </block>
        </referenceContainer>
        <referenceBlock name="logo">
            <arguments>
                <argument name="logo_img_width" xsi:type="number">148</argument>
                <argument name="logo_img_height" xsi:type="number">43</argument>
            </arguments>
        </referenceBlock>
        <referenceContainer name="footer">
            <block class="Magento\Store\Block\Switcher" name="store_switcher" as="store_switcher" after="footer_links" template="switch/stores.phtml"/>
            <block class="Magento\Framework\View\Element\Template" name="footer_social" template="Magento_Theme::html/footer_social.phtml">
        </referenceContainer>
        <referenceBlock name="report.bugs" remove="true"/>
        <move element="copyright" destination="before.body.end"/>
    </body>
</page>

1 Answer 1

1

since the store switcher is already added in the luma theme, you should not add it again in your theme to the footer (to be honest I'm not 100% sure if it gets overridden or maybe cause an error when you add a block with the same name)

For your issue, I think it's just an xml fault. You did not close the block tag correctly https://stackoverflow.com/questions/7231902/self-closing-tags-in-xml-files

Just try this (trailing slash added):

<block class="Magento\Framework\View\Element\Template" name="footer_social" template="Magento_Theme::html/footer_social.phtml"/>
2
  • Thanks for the reply. I have tried what you mentioned and the problem persists. My block is still not visible on the site. I have been wondering if my link to the template phtml file is correct. Magento_Theme:: will always reference my child theme template directory? Commented Mar 4, 2016 at 23:07
  • Ok sorted! I didn't realise Magento_Theme::html actually references my_theme/Magento_Theme/templates/html/ Commented Mar 4, 2016 at 23:34

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.