Add link to customer-menu
Question
I need to add a custom link to the dropdown menu :
<div class="customer-menu" data-target="dropdown">
How can I do this easily (without using jquery), I need to do it the magento way
Solution
You can create/copy a default.xml file and add your custom link there.
If your current/parent theme is Luma, use the top.links.
app/design/frontend/vendor/theme/Magento_Customer/layout/default.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="top.links">
<block class="Magento\Framework\View\Element\Html\Link\Current" name="my-custom-contact-link">
<arguments>
<argument name="label" xsi:type="string" translate="true">My Contact</argument>
<argument name="path" xsi:type="string">contact</argument>
<argument name="sortOrder" xsi:type="number">110</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>
If your current/parent theme is Blank, use the header.links.
app/design/frontend/vendor/theme/Magento_Customer/layout/default.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="header.links">
<block class="Magento\Framework\View\Element\Html\Link\Current" name="my-custom-contact-link">
<arguments>
<argument name="label" xsi:type="string" translate="true">My Contact</argument>
<argument name="path" xsi:type="string">contact</argument>
<argument name="sortOrder" xsi:type="number">110</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange