【问题标题】:Magento: Call custom phtml in list.phtml via XMLMagento:通过 XML 在 list.phtml 中调用自定义 phtml
【发布时间】:2012-09-05 21:57:59
【问题描述】:

在 Magento 中,我试图在 list.phtml 中显示一个 phtml 自定义模块。 我的 xml 看起来像这样:

<catalog_category_default>
    <reference name="content">
            <block type="my_prevenda/prevendalist" name="prevenda" as="prevenda" template="prevenda/prevenda_list.phtml" />
    </reference>
</catalog_category_default>

我这样打电话:&lt;?php echo $this-&gt;getChildHtml('prevenda') ?&gt;

但是这个方法只存在于view.phtml中。 我如何出现在 list.phtml 中? 将保留产品名称

I Tks all!!

【问题讨论】:

    标签: xml magento module block


    【解决方案1】:
    <?xml version="1.0"?>
    <layout>
        <catalog_category_default>
            <reference name="product_list"><!-- need to add to the correct parent block -->
                    <block type="my_prevenda/prevendalist"
                           name="prevenda" as="prevenda"
                           template="prevenda/prevenda_list.phtml" />
            </reference>
        </catalog_category_default>
    </layout>
    

    【讨论】:

    • 谢谢,但是没有用。我认为问题出在这里: 也许不应该是这个参考,但我不知道是什么。
    • Mesmo alterando para não aparece.
    • 连改成都不出现。
    • &lt;default&gt; 不起作用,因为 product_list 块指令是 catalog_category_default 句柄的一部分。您是否正在刷新布局 XML 缓存?如果您破坏(添加无效语法)您的布局 XML,您会看到解析错误吗?如果没有,请启用开发者模式并解决该问题。
    • 对不起,缓存被禁用但不知道为什么它不起作用。我在管理员中释放了缓存并且它起作用了。谢谢!!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-21
    • 2016-09-19
    • 2013-02-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多