How to customise the Magento navbar (Topmenu.php vs Topmenu.phtml)

Posted by Labels: at

So today I was trying to customise the nav bar of my Magento store, just like any other front end developer, I turned on my template hints, and navigated the file Topmenu.phtml.

File path: app/design/frontend/package_name/theme_name/template/page/html/topmenu.phtml

But to my surprise, this is all i found.



 echo $_menu;


"Ah! Where are the ul and li tags?" well not to worry i did some digging, and found a .php file responsible for populating the navigation bar (Topmenu.php).

File path: app/code/core/Mage/Page/Block/Html/Topmenu.php

Before editing this file, you need to copy it your local folder... if you do not have local/ create it under app/code/

copy to File path: app/code/local/Mage/Page/Block/Html/Topmenu.php

This is where the variable $_menu is declared and populated.


protected $_menu;

public function getHtml($outermostClass = '', $childrenWrapClass = ''){
     <!--ul and li tags are created here-->
}


Sometimes Magento can get tricky at first glance, but this is what this blog is here for, to help you get started. If you found this article to be informative, let me know below on the comments section or leave a question.
Post a Comment

Back to Top