0

I was trying to do something like this in my theme folder's default.xml

<referenceBlock name="footer_social_links">
    <block class="Magento\Framework\View\Element\Html\Link" name="social.link" after="">
    <arguments>
        <argument name="label" xsi:type="string" translate="true">Contact Us</argument>
        <argument name="class" xsi:type="string" translate="false">contact</argument>
        <argument name="path" xsi:type="string">contact</argument>
    </arguments>
    </block>
</referenceBlock>

It isn't working at the moment. What I'm wanting to do is add some facebook icon and twitter icon linking to a specific page (pretty normal?). I couldn't find other answers on the stackexchange here for Magento 2.

This was using XML code. Do I need to do in PHTML? I changed the "footer_links" to add custom links already with XML so I thought this was very similar that it would also be done in XML.

Footer Appearance

I want to add it along the right, under the subscribe section. How do I implement, and then where do I put the styles? _theme.less only and it links by just the class name?

1

Have you already added the footer_social_links block? referenceBlock should only be used with already defined blocks. If you haven't already created this block you'll need to add it using block instead of referenceBlock.


Personally I would add a template with your social media links/icons, then call this template within the XML. Like so:

<referenceBlock name="footer_social_links">
     <block class="Magento\Framework\View\Element\Template" name="social.link" template="Magento_Theme::social-links.phtml" before="-"/>
</referenceBlock>

This creates a block within footer_social_links, this block uses the template in Magento_Theme/templates/social-links.phtml - Here you can add your content.

If this doesn't work then check that the block footer_social_links is displaying correctly.

2
<referenceBlock name="footer">
            <block class="Magento\Cms\Block\Block" name="footer_social_links_block">
            <arguments>
                <argument name="block_id" xsi:type="string" translate="true">dth_footer_social_links</argument>
            </arguments>
            </block>
        </referenceBlock>

In my app/design/frontend/my_custom_name/theme_folder/Magento_Theme/layout/default.xml I added the block above. Then I made a static block inside the admin with of course block id of dth_footer_social_links

<div class="social-links" style="float: right; margin-right: 30px;">
  <a href="www.facebook.com/">DTH Facebook img here</a> <br />
  <a href="www.twitter.com/">DTH Twitter img here</a>
</div>

As you can see I used inline styles here, but I plan on moving these styles to the theme's less file that is _theme.less and using the class social-links. For now inline-styles will work.

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.