0

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

2

1 Answer 1

3

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>
1
  • Yes, that's what I've done 2mins ago, this is it. Thanks ! Commented Oct 8, 2018 at 9:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.