Php Magento自定义块模板未显示
我创建了自己的模块,将相关产品添加到产品页面,这仅显示具有相同品牌/制造商的相关产品 但是我遇到了一个问题,模板文件不会显示在页面上 这是我到目前为止所拥有的 app/code/community/CustomMod/RelatedBrand/etc/config.xmlPhp Magento自定义块模板未显示,php,magento,Php,Magento,我创建了自己的模块,将相关产品添加到产品页面,这仅显示具有相同品牌/制造商的相关产品 但是我遇到了一个问题,模板文件不会显示在页面上 这是我到目前为止所拥有的 app/code/community/CustomMod/RelatedBrand/etc/config.xml <?xml version="1.0" encoding="UTF-8"?> <config> <modules> <CustomMod_RelatedBra
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<CustomMod_RelatedBrand>
<version>0.0.1</version>
</CustomMod_RelatedBrand>
</modules>
<global>
<blocks>
<relatedbrand>
<class>CustomMod_RelatedBrand_Block</class>
</relatedbrand>
</blocks>
</global>
</config>
0.0.1
CustomMod\u相关品牌块
app/code/community/CustomMod/RelatedBrand/Block/Related.php
<?php
class CustomMod_RelatedBrand_Block_Related extends Mage_Catalog_Block_Product_View {
public function _toHtml() {
echo "Block's _toHtml() method called!";
parent::_toHtml();
}
}
?>
当我导航到一个产品页面时,我可以看到Block的_toHtml()方法调用
但是没有显示HELLO,我就是不明白为什么。有人知道我错过了什么吗?
public function _toHtml() {
echo "Block's _toHtml() method called!";
parent::_toHtml();
}
应该是:
public function _toHtml() {
echo "Block's _toHtml() method called!";
return parent::_toHtml();
}
Mage\u Core\u Block\u模板中的\u toHtml
方法不回显内容。它只是返回它。在您的例子中,该方法返回null
哇,就是这样。非常感谢,最近一个小时一直在扯我的头发!我现在觉得有点傻:P@Karl不客气。不要觉得自己有点愚蠢——即使我会:)。像这样的事情经常发生。有人告诉我“只有傻瓜才会害怕寻求帮助”。
<?php echo $this->getChildHtml('related_brand') ?>
public function _toHtml() {
echo "Block's _toHtml() method called!";
parent::_toHtml();
}
public function _toHtml() {
echo "Block's _toHtml() method called!";
return parent::_toHtml();
}