我已经在magento中下载了一个自定义模块,它使用引用将块加载到布局中:
<reference name="content">
<block type="ibanner/content_top" name="ibanner_content_top" template="my_ibanner/content/top.phtml" before="-"/>
<block type="ibanner/content_bottom" name="ibanner_content_bottom" template="my_ibanner/content/bottom.phtml" after="-"/>
</reference>
此代码工作正常。但是,如果我使用标题refence,页面上没有显示横幅,我无法弄清楚为什么......
如果我使用page_two_columns_left布局并引用左侧名称布局块,横幅显示,我无法分辨块之间的差异,使其中一些加载baner而其他人不会。
如果有人可以帮我解决这个问题,我会真的对此表示赞同。
问候。
答案 0 :(得分:1)
在不同路由中“注入”块的一部分取决于父块。 “content”和“left”是core/text_list
块(Mage_Core_Block_Text_List
),它们不会使用模板而只是渲染所有子块。但是,如果块使用模板,则必须(应该)采取两个步骤:
<?php echo $this->getChildHtml("ibanner_content_top") ?>
。请注意,包含空getChildHtml()
调用的模板文件将呈现所有子块。