I'm extending app/code/core/Mage/Page/Block/Html/Topmenu.php with the following xml:
<config>
<modules>
<Custom_Menu>
<version>1.0</version>
</Custom_Menu>
</modules>
<global>
<blocks>
<page>
<rewrite>
<html_topmenu>Custom_Menu_Block_Page_Html_Topmenu</html_topmenu>
</rewrite>
</page>
</blocks>
</global>
</config>
And my class definition:
class Custom_Menu_Block_Page_Html_Topmenu extends Mage_Page_Block_Html_Topmenu
{
}
Even with my class not overriding any methods, the following template file just doesn't get processed:
app/design/frontend/base/default/template/page/html/topmenu.phtml
I'm not overriding the template file.
As soon as I disable my module, it starts working again.
Do I need to declare anything else in my xml file?
Do this change in your config.xml file
<html_topmenu>Custom_Menu_Block_Html_Topmenu</html_topmenu>
and change your class name to
class Custom_Menu_Block_Html_Topmenu extends Mage_Page_Block_Html_Topmenu
{
}
One thing springs to mind. You may have your class file in the wrong place. Your rewrite code looks correct, so when Magento instantiates a page/html_topmenu
block it correctly resolves it to your Custom_Menu_Block_Page_Html_Topmenu
class name. However, Magento may not be able to find the class Custom_Menu_Block_Page_Html_Topmenu
. Try running the code
$block = new Custom_Menu_Block_Page_Html_Topmenu;
var_dump($block);
from an empty controller and/or bootstrap file to ensure that Magento can find your class. It also wouldn't hurt to run
$block = Mage::getSingleton('core/layout')->createBlock('page/html_topmenu');
var_dump($block);
To ensure your rewrite is doing what it needs to do.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.