7

Hello everybody,

I want to reorder my top links. For example i just want that Login comes first than my whishlist or my cart. I know there is a position tag to position the toplink, but it does not work.

In my site order is register mywhishlist mycart logout myaccount.

before login order should be mywhishlist mycart login register myaccount. after login order should be mywhishlist mycart register logout myaccount.

Please help me. Thanks.

2
  • Can you please post the part of XML where you are trying to change the order? Commented Sep 17, 2013 at 7:08
  • I have experienced the same issue in 1.9, i can set position to 1000000 but the links are added in the xml order like the position is relative only to the links being added at the same time.
    – Walf
    Commented Oct 10, 2014 at 1:02

4 Answers 4

7

After bashing my head against the wall for a while, I've discovered that the XML is lying to you. It only appears as though the child nodes of <action method="addLink"> are associative. In actual fact, they are an ordered list that correspond to the arguments of Mage_Page_Block_Template_Links::addLink(). Thus the XML node names have no affect, they are simply there so it's more readable than <arg0>, <arg1>, etc.

In summary your nodes must always go:

<label>
<url>
<title>
<prepare>
<urlParams>
<position>
<liParams>
<aParams>
<beforeText>
<afterText>

You may only omit empty nodes after the last non-empty node, e.g.:

<label>Foo Bar</label>
<url>foo-bar</url>
<title>Foo Bar</title>
<prepare/>
<urlParams/>
<position>200</position>
1
  • Briljant!! Saved me a big headache, thanks! Commented Jun 24, 2016 at 11:43
3

Hello checko below file into your template layout xml

wishlist.xml

<action method="addLinkBlock"><blockName>wishlist_link</blockName><prepare/><urlParams/><position>10</position></action>

checkout.xml

<action method="addCartLink"><prepare/><urlParams/><position>30</position></action>

customer.xml

<action method="addLink" translate="label title" module="customer"><label>My Account</label><url helper="customer/getAccountUrl"/><title>My Account</title><prepare/><urlParams/><position>100</position><liParams/></action>
<action method="addLink" translate="label title" module="customer"><label>Log Out</label><url helper="customer/getLogoutUrl"/><title>Log Out</title><prepare/><urlParams/><position>50</position></action>
<action method="addLink" translate="label title" module="customer"><label>Log In</label><url helper="customer/getLoginUrl"/><title>Log In</title><prepare/><urlParams/><position>50</position><liParams/></action>

we will see Default Position In Magento

My Account = 10 Path-> app\design\frontend\default\default\layout\customer.xml

Whislist = 30 Path-> app\code\core\Mage\Wishlist\Block\Links.php

Mycart = 50 Path-> app\code\core\Mage\Checkout\Block\Links.php

Checkout = 60-> Path-> app\code\core\Mage\Checkout\Block\Links.php

Login/Logout = 100 Path-> app\design\frontend\default\default\layout\customer.xml

0

You can re-order topLinks by adding or updating "position" tag in layout xml file.

Eg:. Below is code For My Account Link in [Magento root folder]/app/design/frontend/base/default/layout/customer.xml inside handle "customer_logged_out".

  <reference name="top.links">
        <action method="addLink" translate="label title" module="customer"><label>Log In</label><url helper="customer/getLoginUrl"/><title>Log In</title><prepare/><urlParams/><position>100</position></action>
    </reference>

You can create your own theme and update position value from 100 to 10 inside action tag in above code.

0

You can reorder your toplinks by using position attribute in layout xml files. As in customer.xml file, the order of Login and Logout can be changed from this file and same as from wishlist.xml and checkout.xml.

<customer_logged_in>
    <reference name="top.links">
                    <action method="addLink" translate="label title" module="customer"><label>Log Out</label><url helper="customer/getLogoutUrl"/><title>Log Out</title><prepare/><urlParams/><position>100</position></action>
            </reference>
</customer_logged_in>

<customer_logged_out>
     <reference name="top.links">
                    <action method="addLink" translate="label title" module="customer"><label>Log In</label><url helper="customer/getLoginUrl"/><title>Log In</title><prepare/><urlParams/><position>100</position></action>
            </reference>
</customer_logged_out>

Hope this will help you.

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.