1

I was working with the layout xml for the top links. My code is in my custom module default.xml:

<?xml version="1.0"?>

<body>
    <referenceBlock name="header.links">
        <block class="Magento\Framework\View\Element\Html\Link\Current" name="storelocator-link">
            <arguments>
                <argument name="label" xsi:type="string" translate="true">Title Link</argument>
                <argument name="path" xsi:type="string">link-uri</argument>
            </arguments>
        </block>
    </referenceBlock>
</body>

Now I can get my link in top.links area. But it shows at the beginning. I like to move it at the end... But I can't able to move it. Can anyone help me to fix its position to the end..

3

try this it helps you if it work accept the answer it help others

<?xml version="1.0"?>
<body>
  <referenceBlock name="header.links">
        <block class="Magento\Customer\Block\Account\RegisterLink" name="register-link-new"  after="-">
            <arguments>
                <argument name="label" xsi:type="string" translate="true">Create an Account</argument>
            </arguments>
        </block>
        <block class="Magento\Framework\View\Element\Html\Link\Current" name="storelocator-link" after="register-link-new">
            <arguments>
                <argument name="label" xsi:type="string" translate="true">Title Link</argument>
                <argument name="path" xsi:type="string">link-uri</argument>
            </arguments>
        </block>
    </referenceBlock>
    <referenceBlock name="register-link" remove="true"/>


</body>
  • Such approach may break other modules (e.g. other extensions), which rely on register-link block. – Alex Paliarush Dec 17 '15 at 7:41
  • @Alex:- in complete project no where it used – Pradeep Kumar Dec 18 '15 at 3:39
  • @PradeepKumar merchant can install another extension in the future, which may use it. – Alex Paliarush Dec 18 '15 at 6:39
0

Try to place your module after the module(s)that place the other links, I mean as dependecie of the other(s) module(s).

  • Other links I have like "Sign in" and "Create an account" which is dependent on the customer module so that I have done my squence in my custom module: module.xml <sequence> <module name="Magento_Store"/> <module name="Magento_Customer"/> </sequence> But still it not go to the end... – Soumik Tuban Dec 17 '15 at 5:16
  • Ok, another try... can you check the markup on page source (if perhaps link are right floating you will see them in reverse order). Another possible workaround would be search for some after/before flag in layout. – MauroNigrele Dec 17 '15 at 6:45

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.