【问题标题】:Using getChildHtml inside included template magento在包含的模板 magento 中使用 getChildHtml
【发布时间】:2011-04-14 09:19:13
【问题描述】:

我正在尝试在 Magento 的 page/html/header.phtml 文件中使用 $this->getChildHtml('head')

page/1column.phtml 文件中使用$this->getChildHtml('head') 可以按预期工作。

有人能指出我正确的方向来理解$this 是如何在模板中使用的吗?

我认为这个Stack overflow question, Magento - using $this->getPriceHtml on custom page template 是正确的,但我仍然缺少一些东西。谢谢

【问题讨论】:

    标签: php templates magento


    【解决方案1】:

    在这里,您正在进入“比您所在的世界更大的世界中的世界”综合症。您不能使用它,因为 head 未定义为您当前所在块的子级。

    试试这个:

    <?php echo $this->getLayout()->getBlock('head')->toHtml();?> 
    

    【讨论】:

    • +1 谢谢,你的解决方案第一次没用,因为我忘了echo它!
    • 我喜欢你综合症的名字:)
    • 如何修复not defined a child of your block 部分??
    • @mrN 您将其引用到您的布局节点。简单
    • @AntonS,我很基础,你能指出我的资源吗.. 详细说明你在说什么。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-29
    • 2012-07-18
    • 2013-06-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多