Magento – Magento 1.7 – Override Navigation.php

ce-1.7.0.2navigation

I've what seems like it should be a fairly easy fix… in Magento 1.7 CE, I just want to add title attributes to my primary navigation links. I attempted to duplication Navigation.php, as described here: http://seechrisblog.com/2010/05/28/how-to-add-title-attributes-to-magentos-main-nav/, however this has had no effect.

Can anyone tell me how I can override Navigation.php in this version of Magento?

-thanks!

Best Answer

I've been saying this a lot lately, but nobody pays attention :).
Starting with CE 1.7 (and EE 1.12) the top menu is not rendered anymore by Navigation.php. That is only used for rendering catalog.leftnav (Browse By Category).
The top menu is an instance of Mage_Page_Block_Html_Topmenu. The method responsable for generating the HTML for the menu is _getHtml in the class I mentioned above. You can override that and change this code (somewhere around line 114 in the original class file):

$html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . '><span>'
          . $this->escapeHtml($child->getName()) . '</span></a>';

to

$html .= '<a href="' . $child->getUrl() . '" ' . $outermostClassCode . ' title="'.$this->escapeHtml($child->getName()) .'"><span>'
         . $this->escapeHtml($child->getName()) . '</span></a>';
Related Topic