Magento自定义块模板未显示

卡尔

我创建了自己的模块,将相关产品添加到产品页面,该模块仅显示具有相同品牌/制造商的相关产品。

但是,我遇到了一个问题,即模板文件不会显示在页面上。

到目前为止,这就是我所拥有的。

应用程序/代码/社区/CustomMod/RelatedBrand/etc/config.xml

<?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>

应用程序/代码/社区/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();
    }
}
?>

然后在catalog.xml文件中,在catalog_product_view区域中添加了以下内容:

<block type="relatedbrand/related" name="related_brand" as="related_brand" template="relatedbrand/view.phtml"/>

然后在design / frontend / MYPACKAGE / default / relatedbrand / view.phtml中,我有:

<?php echo 'HELLO'; ?>

同样在catalog / product / view.phtml中,我添加了:

<?php echo $this->getChildHtml('related_brand') ?>

当我导航到产品页面时,可以看到未显示,Block's _toHtml() method called!但是HELLO我无法弄清楚原因。有人知道我可能错过了什么吗?

马吕斯

public function _toHtml() {
    echo "Block's _toHtml() method called!";
    parent::_toHtml();
}

应该:

public function _toHtml() {
    echo "Block's _toHtml() method called!";
    return parent::_toHtml();
}

_toHtml方法Mage_Core_Block_Template从不回显内容。它只是返回它。在您的情况下,该方法返回null

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

在自定义页面Magento上显示自定义静态块

来自分类Dev

Magento 2自定义主题CSS未显示

来自分类Dev

VS2019自定义模板未显示

来自分类Dev

Wordpress自定义模板未显示在自定义帖子类型中

来自分类Dev

如何在模板文件中加载自定义PHP Magento块

来自分类Dev

Magento自定义静态块在模板中不存在

来自分类Dev

Magento:注册用于静态块小部件的自定义模板文件

来自分类Dev

我在Drupal 8中的自定义块未显示在块布局中

来自分类Dev

是否可以在自定义模块中显示magento产品列表块

来自分类Dev

Magento如果属性值为x或y,则显示自定义块

来自分类Dev

Magento如果属性值为x或y,则显示自定义块

来自分类Dev

如何在Magento Fishpig中的自定义模板上显示类别帖子?

来自分类Dev

Drupal 7:自定义模块:在自定义块中显示自定义内容

来自分类Dev

尝试在magento中创建自定义块

来自分类Dev

自定义块和Magento搜索结果侧栏

来自分类Dev

Magento 1.9:向标题添加自定义块

来自分类Dev

Magento,覆盖自定义模块adminhtml块

来自分类Dev

应用自定义窗口样式和模板(C#,WPF)后未显示验证错误

来自分类Dev

自定义模板暴露的过滤器的Drupal 7视图未显示

来自分类Dev

Django自定义500错误模板未显示request.user

来自分类Dev

具有自定义模板公开过滤器的Drupal 7视图未显示

来自分类Dev

自定义实时模板未显示在 xhtml JSF 文件中

来自分类Dev

自定义指令未显示

来自分类Dev

IdentityServer未显示自定义视图

来自分类Dev

android:自定义视图未显示

来自分类Dev

自定义UIViewController的视图未显示

来自分类Dev

自定义线性布局未显示

来自分类Dev

Android自定义属性未显示

来自分类Dev

自定义嵌入未显示

Related 相关文章

热门标签

归档