Magento:阻止替代会阻止phtml显示

编程入门 行业动态 更新时间:2024-10-22 07:57:27
本文介绍了Magento:阻止替代会阻止phtml显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在研究Magento项目,并且已覆盖Page Html Header块,因为我需要更改getLogoSrc()函数的方式(我在app/code/core/Mage/Page/Block/Html中找到了此功能) /Header.php).但是我似乎做错了什么,因为header.phtml不再被绘制.

I'm working on a Magento project and I've overridden the Page Html Header block because I need to change how the getLogoSrc() function (which I found in app/code/core/Mage/Page/Block/Html/Header.php). However I seem to have done something incorrectly as header.phtml is no longer being drawn.

app/code/local/NameSpace/Customize/Block/Html/Header.php

app/code/local/NameSpace/Customize/Block/Html/Header.php

class NameSpace_Page_Block_Html_Header extends Mage_Page_Block_Html_Header { ...Code... }

app/code/local/NameSpace/Customize/etc/config.xml

app/code/local/NameSpace/Customize/etc/config.xml

<config> <modules> <NameSpace_Customize> <version>0.1.0</version> </NameSpace_Customize> </modules> <helpers> <customize> <class>NameSpace_Customize_Helper</class> </customize> </helpers> <global> <blocks> <page> <rewrite> <html_header>NameSpace_Page_Block_Html_Header</html_header> </rewrite> </page> </blocks> </global> </config>

app/etc/modules/NameSpace_Customize.xml

app/etc/modules/NameSpace_Customize.xml

<config> <modules> <NameSpace_Customize> <active>true</active> <codePool>local</codePool> </NameSpace_Customize> </modules> </config>

当我删除config.xml中<global>标记内的所有内容时,标题将正确显示.

When I remove everything inside of the <global> tags in config.xml the header is displayed correctly.

这是我的第一个Magento项目,所以我可能做错了这条路.任何输入将不胜感激.

This is my first Magento project so I may have gone about this the wrong way. Any input would be appreciated.

谢谢

推荐答案

块类名称必须与它所在的文件夹匹配.

The block class name must match the folder it is in.

class NameSpace_Customize_Block_Html_Header extends Mage_Page_Block_Html_Header { // do not write any more in here until you've tested at least once }

也对config.xml进行了相同的更改.另外,<helpers>节点必须在<global>节点内部.

Make the equivalent change in config.xml too. Also the <helpers> node must be inside the <global> node.

<config> <modules> <NameSpace_Customize> <version>0.1.0</version> </NameSpace_Customize> </modules> <global> <helpers> <customize> <class>NameSpace_Customize_Helper</class> </customize> </helpers> <blocks> <page> <rewrite> <html_header>NameSpace_Customize_Block_Html_Header</html_header> </rewrite> </page> </blocks> </global> </config>

更多推荐

Magento:阻止替代会阻止phtml显示

本文发布于:2023-11-25 02:52:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1628024.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Magento   phtml

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!