0

I am trying to add a button called "social media" to be beside the Storeview switcher. I tried to follow the answer in: Magento 2 - Add a Custom Button to header.phtml

So I created a CMS block on the backend called 'social media' with id 'social_media'.

I also add the following to the: app/design/frontend/Smartwave/porto/Smartwave_Porto/layout/default.xml file:

<referenceBlock name="header.links">
    <block class="Magento\Cms\Block\Block" name="social.media" before="-">
        <arguments>
            <argument name="block_id" xsi:type="string">social_media</argument>
        </arguments>
    </block>
</referenceBlock>

However, it didn't work.

So my question: what is the right way to add such a button to the header links in magento 2.3.5 ?

1
0

app/design/frontend/[Package]/[Theme]/Magento_Theme/layout/default.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="top.links">
           <block class="Magento\Cms\Block\Block" name="button.link" before="-">
             <arguments>
                <argument name="block_id" xsi:type="string">social_media</argument>
            </arguments>
           </block>
        </referenceContainer>

        <move element="button.link" destination="top.links" before="-" />

    </body>
</page>

screen shot attached.

enter image description here

Hope this will help you. thanks

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.