Magento – way to add a class name to a category link

categorycssmagento-1.7menu

I have a menu on my Magento website generated from my categories.

For this menu I am using images. The problem is when I remove a category then the image for the links are not attach to the right link… Because the classes that I am using for CSS are numbered and not named.

So is there a way to add my own class for a category link?

Best Answer

Sadly changes to the Catalog Navigation are not that easy. The function that does all the work is Mage_Catalog_Block_Navigation::_renderCategoryMenuItemHtml

This adds the category link with the following lines:

$html[] = '<a href="'.$this->getCategoryUrl($category).'"'.$linkClass.'>';
$html[] = '<span>' . $this->escapeHtml($category->getName()) . '</span>';
$html[] = '</a>';

I would suggest that the best way to do this would be to create a module that rewrites this class you you could change these lines to meet your needs.