drgc9632 2012-09-19 09:48
浏览 28

Magento - 扩展Topmenu.php块会停止topmenu.phtml模板加载

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?

  • 写回答

2条回答 默认 最新

  • dongliqin6939 2012-09-19 17:04
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题