Subesh Pokhrel

Magento Developers Blog

Adding CSS Class Name to My Account Link (Anchor Tag) in Magento Through XML Layout

At the first instance I thought WTH! must be pretty simple, add params in XML layout and ”Voila!”. But later I found that it was not simpler as I thought. I had to get into the addLink method for sometime (1/2hr) and finally I came up with correct structure of XML layout. At the end it again seemed simple though, but it needed a healthy effort. Here’s the XML structure of layout from customer.xml where you add class to My Account link. [source language=”xml”] <!– customer.xml–> <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/> <urlParams/> <class/> <position>10</position> <aParams> <class>my-class-name</class> </aParams> </action> </reference> <!– customer.xml–> [/source] One notable thing in the structure above is the aParams which is responsible for adding the class to the Anchor tag, not the List tag. Hope this helps someone! Happy Coding.