LinkedIn Twitter RSS Reset

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.

<!-- 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-->

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.

2 Responses to “Adding CSS Class name to My Account Link (Anchor Tag) in Magento through XML Layout”

  1. Mike
    November 24, 2010 at 12:16 am #

    Has anyone figured out how to add an ID or Class to the li?

    Thanks!

Trackbacks/Pingbacks

  1. Tweets that mention Adding CSS Class name to My Account Link (Anchor Tag) in Magento through XML Layout | Subesh Pokhrel's Blog - Magento Development Tips -- Topsy.com - September 24, 2010

    [...] This post was mentioned on Twitter by Mattias Grenhall and Web Design Magazine, Subesh Pokhrel. Subesh Pokhrel said: New Blog Post: http://subesh.com.np/2010/09/adding-css-class-name-to-my-account-link-anchor-tag-in-magento-through-xml-layout/ #Magento [...]

Leave a Comment