Magento 2 - Add button to the Header links
-
14-04-2021 - |
質問
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 ?
正しい解決策はありません
他のヒント
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.
Hope this will help you. thanks
所属していません magento.stackexchange