How to add class in top links?
magento
Solution
As you have discovered, the method signature for addLink is:
public function addLink($label, $url='', $title='', $prepare=false, $urlParams=array(), $position=null, $liParams=null, $aParams=null, $beforeText='', $afterText='')
So a proper call in a layout, using all the parameters, would be:
<action method="addLink">
<label/>
<url/>
<title/>
<prepare/>
<urlParams/>
<position/>
<liParams/>
<aParams/>
<beforeText/>
<afterText/>
</action>
Unfortunately Magento is not using reflection to map the action element children to named parameters of the method and is instead depending upon position.
One additional note, liParams and aParams can either be a string or a series of child elements representing key/value pairs.
Problem
I tried to add class to top links by using `<aParams>class="class-name"</aParams>` For example: ``` <reference name="top.links"> <action method="addLink" translate="label title" module="customer"><label>My Account</label><url helper="customer/getAccountUrl"/><title>My Account</title><prepare/><aParams>class="top-link-myaccount"</aParams><position>10</position></action> </reference> ``` Above trick didn't work for me at least for 1.7.0.0 version. Any idea? Edit: I think i fixed it using `<li/><a>class="top-links-register"</a>`: ``` <reference name="top.links"> <action method="addLink" translate="label title" module="customer"><label>My Account</label><url helper="customer/getAccountUrl"/><title>My Account</title><prepare/><aParams/><position>10</position><li/><a>class="top-link-myaccount"</a></action> </reference> ``` Note that you must prepend `<li/>`