Magento – How do add a class to the Wishlist Link in the Top Menu

classmagento-1.7toplinkstopmenuwishlist

I want to add a class to the wishlist link in the top menu.

In my app/design/frontend/default/abcd/layout/wishlist.xml, I have a reference:

<reference name="top.links">
    <block type="wishlist/links" name="wishlist_link" />
    <action method="addLinkBlock"><blockName>wishlist_link</blockName></action>
</reference>

I know you can add a class using the addLink method as described in this answer. However the addLinkBlock method only takes one blockName argument. So how can I add a class to the wishlist link in the top menu?

Best Answer

I followed some suggestions from this Magento Forum post, but none of them did the trick for me, but the last one was close. Here's what I did:

  1. Copy /app/code/core/Mage/Wishlist/Block/Links.php to /app/code/local/Mage/Wishlist/Block/Links.php
  2. Inside the _toHtml() method, add $this->a_params = 'class="your-class"'; just before the return parent::_toHtml(); statement