I am using Magento Enterprise Edition. It includes a widget for banners, which I want to use inside of my template, rather than from inside of a CMS-run content block. I succeeded in generating the output from inside of a content block:
我正在使用Magento企业版。它包括一个横幅小部件,我想在我的模板中使用它,而不是从CMS运行的内容块内部。我成功地从内容块内部生成输出:
{{widget type="enterprise_banner/widget_banner" display_mode="fixed" rotate="series" banner_ids="4" template="banner/widget/block.phtml" unique_id="744a56c9a042cc9fa166163c12d869d9"}}
Simple enough. So inside of my layout xml, I tried this:
很简单。所以在我的布局xml中,我尝试了这个:
<block type="enterprise_banner/widget_banner" name="hero_banners" as="hero_banners" display_mode="fixed" rotate="series" banner_ids="4" template="banner/widget/block.phtml" unique_id="744a56c9a042cc9fa166163c12d869d9" />
Same parameters; I just added name and as. And then, inside of my template...
相同的参数;我只是添加了名字和as。然后,在我的模板中......
<?php echo $this->getChildHtml('hero_banners'); ?>
But I get no output. The profiler notes that the hero_banners block is loaded, but its template file (banner/widget/block.phtml) is never run.
但我没有输出。分析器注意到已加载hero_banners块,但其模板文件(banner / widget / block.phtml)从未运行。
Does anybody know what I'm doing wrong?
有人知道我做错了什么吗?
-P
-P
2 个解决方案
#1
19
Turns out, it wasn't inserting any meaningful data because it wasn't receiving its parameters. It needs non-standard parameters to be set through action tags:
事实证明,它没有插入任何有意义的数据,因为它没有接收到它的参数。它需要通过动作标签设置非标准参数:
<block type="enterprise_banner/widget_banner" name="hero_banners" as="hero_banners" template="banner/widget/hero.phtml">
<action method="setDisplayMode"><value>fixed</value></action>
<action method="setBannerIds"><value>4</value></action>
</block>
#2
2
Since the topic has already been solved, I have an off topic solution
由于该主题已经解决,我有一个非主题解决方案
This could be set as a block within a .phtml file if required.
如果需要,可以将其设置为.phtml文件中的块。
<?php echo $this->getLayout()->createBlock('enterprise_banner/widget_banner')->setBannerIds('4')->setDisplayMode('fixed')->setTemplate('banner/widget/block.phtml')->toHtml(); ?>
#1
19
Turns out, it wasn't inserting any meaningful data because it wasn't receiving its parameters. It needs non-standard parameters to be set through action tags:
事实证明,它没有插入任何有意义的数据,因为它没有接收到它的参数。它需要通过动作标签设置非标准参数:
<block type="enterprise_banner/widget_banner" name="hero_banners" as="hero_banners" template="banner/widget/hero.phtml">
<action method="setDisplayMode"><value>fixed</value></action>
<action method="setBannerIds"><value>4</value></action>
</block>
#2
2
Since the topic has already been solved, I have an off topic solution
由于该主题已经解决,我有一个非主题解决方案
This could be set as a block within a .phtml file if required.
如果需要,可以将其设置为.phtml文件中的块。
<?php echo $this->getLayout()->createBlock('enterprise_banner/widget_banner')->setBannerIds('4')->setDisplayMode('fixed')->setTemplate('banner/widget/block.phtml')->toHtml(); ?>