Magento – How to reorder toplinks

magento-1.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.

Best Answer

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>