Change or change Magento entry and exit position (top links) using local.xml

I would like to change my top links using local.xml - in particular, input / output links. Is this possible without deleting links, re-adding them and changing their position tags?

Currently (and by default) "Entry and Exit" are set to position 100 in customer.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> 

I would like them both to be in position 1 (via local.xml ).

I know the setAttribute action setAttribute , but I'm not sure how to use it in this case.

+4
source share
3 answers

I did not find a more efficient way to do this in local.xml , so I deleted the links and added them again with the changed position parameters:

 <customer_logged_in> <reference name="top.links"> <action method="removeLinkByUrl"><url helper="customer/getLogoutUrl"/></action> <action method="addLink" translate="label title" module="customer"> <label>Log Out</label> <url helper="customer/getLogoutUrl"/> <title>Log Out</title> <prepare/> <urlParams/> <position>4</position> <liParams>id="top-logout"</liParams> <aParams/> </action> </reference> </customer_logged_in> <customer_logged_out> <reference name="top.links"> <action method="removeLinkByUrl"><url helper="customer/getLoginUrl"/></action> <action method="addLink" translate="label title" module="customer"> <label>Log In</label> <url helper="customer/getLoginUrl"/> <title>Log In</title> <prepare/> <urlParams/> <position>4</position> <liParams>id="top-login"</liParams> <aParams/> </action> </reference> </customer_logged_out> 
+3
source

The top.links block addLink used to add links to this block. When you look at the body of this method, you will see that the position parameter is used to determine the position of the links.

The link position is determined by this piece of code:

  $this->_links[$this->_getNewPosition($position)] = $link; if (intval($position) > 0) { ksort($this->_links); } 

_getNewPosition() method checks whether this particular position is available. If this is not the case, then he will look for the nearest available one (i.e., in position 1 there can be only one link). After receiving the correct link position, the entire array of links is sorted.

In your case, the position of both the login and the logout is set to 100 by default (see the <position /> ). So, copy the xml layout ( customer.xml ) into the theme layout directory and change the position parameters to 1.

If these links do not appear in position 1, it means that some other link had a position set to 1 in front of yours. In this case, simply change the position of this link to a larger number. Please note that you cannot use position values ​​less than or equal to zero.

+1
source

The following is the Top Links item number.

based on this, you can set or reposition the top links

 My Account = 10 Whislist = 30 Mycart = 50 Checkout = 60 Login/Logout = 100 
0
source

All Articles