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>

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?


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

You need to rewrite the block Mage_Wishlist_Block_Links and add this as a member variable:

protected $_liPparams = 'class="some-class"';

or if you need the class on the <a> element add this:

protected $_aPparams = 'class="some-class"';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.