I'm currently working on this question: How can I add category IDs as a class on the top menu?
So far, I have set up a new class file that extends Mage_Page_Block_Html_Topmenu
I've included the toHtml and _toHtml functions, and am just trying to return a simple string from those functions to make sure it works. I have also included a simple string saying "HTML Test" outside of the php tags, to check whether or not the file is being included.
Now, I can see "HTML Test" at the top of the page, so my new class file IS being included, but my functions toHtml and _toHtml are not being used.
Here's the details:
My new class file is /app/code/local/Coffeesh0p/Topmenuclasses/Block/Html/Topmenu.php
I have created a config.xml here: /app/code/local/Coffeesh0p/Topmenuclasses/etc/config.xml
config.xml contains the following:
<config>
<modules>
<Coffeesh0p_Topmenuclasses>
<version>1.0</version>
</Coffeesh0p_Topmenuclasses>
</modules>
<global>
<blocks>
<page>
<rewrite>
<html_topmenu>Coffeesh0p_Topmenuclasses_Block_Html_Topmenu</html_topmenu>
</rewrite>
</page>
</blocks>
</global>
And finally, my new Topmenu.php contains the following:
HTML Test
<?php
class Coffeesh0p_Topmenuclasses_Block_Html_Topmenu extends Mage_Page_Block_Html_Topmenu
{
public function getHtml($outermostClass = '', $childrenWrapClass = '')
{
return "TEST1";
}
protected function _getHtml(Varien_Data_Tree_Node $menuTree, $childrenWrapClass)
{
return "TEST2";
}
}
?>
So, why is this file being included but my functions are not being called?
EDIT - I'm using Ultimo theme, and it turns out they use their own menu instead of the default topmenu, so that's why nothing was happening.
Oh well, at least I have learned something about module creation and from the resulting discussion!
<div class="nav-container">
?