【问题标题】:Magento: how to add content to <?php echo $this->getChildHtml('outer-right') ?>Magento:如何向 <?php echo $this->getChildHtml('outer-right') 添加内容?>
【发布时间】:2013-06-10 06:48:12
【问题描述】:

我还在为 magento 苦苦挣扎。 我有一个 3 列布局,但想再放置一个 内容右侧的小部件 &lt;?php echo $this-&gt;getChildHtml('outer-right') ?&gt;.

如何创建包含要输出的内容的 .phtml 文件 当&lt;?php echo $this-&gt;getChildHtml('outer-right') ?&gt; 被调用了?

谢谢。

【问题讨论】:

  • 您是泛指使用术语小部件,还是指 Magento 的 CMS 小部件功能?
  • No Frills Magento Layout 可能与您的兴趣相关(但不值得真正回答)。这是我写的一本电子书,从上到下解释了 Magento 的布局系统,(这在单个 Stack Overflow 问题中很难做到)store.pulsestorm.net/products/no-frills-magento-layout
  • 对不起,如果我使用了整个条款。我不想添加任何复杂的小部件。只需添加一些 html。

标签: magento templates magento-1.7 php


【解决方案1】:

您只需通过 layout.xml 文件在正确布局句柄中名为“outer-right”的块内添加/填充块。当您的布局句柄处于活动状态时,您将能够通过 getChildHtml('outer-right')

获取其 html
<cms_index_index>
<block type="core/template" name="outer-right" template="xyz.phtml">
   <block type="core/template" name="inside-outer-right-1" template="inside.phtml"/>
   <block type="core/template" name="inside-outer-right-2" template="inside2.phtml"/> 
</block>
</cms_index_index>

【讨论】:

  • 谢谢,但我很困惑。什么是 xyz.phtml、inside.phtml、inside2.phtml? cms_index_index 是什么?
  • 另外,我把这段代码放在哪里。理想情况下,我可以编写布局更新代码,但是如何?
  • 如何扩展 cms.xml 以执行以下操作。我是否必须将整个 cms.xml 文件复制到我的布局目录中,还是可以在不复制的情况下对其进行扩展?
  • base/default/layout/cms.xml 中的 cms_index_* 句柄有什么作用?
猜你喜欢
  • 2013-04-08
  • 1970-01-01
  • 2012-06-09
  • 1970-01-01
  • 2013-06-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-05
  • 2014-01-07
相关资源
最近更新 更多