Magento 2: How to add external URL in custom top links
-
11-10-2020 - |
Frage
I would like to add a custom top link which redirects to external URL like Google.com or a blog link etc.
I added the custom top link using referencecontainerBlock
. However, I'm not sure where should I give the link for external URL which I would like to re-direct.
<referenceBlock name="header.links">
<block class="Magento\Framework\View\Element\Html\Link" name="custom-link">
<arguments>
<argument name="label" xsi:type="string" translate="true">custom link</argument>
</arguments>
</block>
</referenceBlock>
Pls advise.
Lösung
You can use path
argumnet to give external link like this:
<block class="Magento\Framework\View\Element\Html\Link" name="custom-link">
<arguments>
<argument name="label" xsi:type="string" translate="true">custom link</argument>
<argument name="path" xsi:type="string" translate="true"><![CDATA[http://www.google.com]]></argument>
</arguments>
</block>
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit magento.stackexchange