【问题标题】:I am getting a block twice in Magento?我在 Magento 中两次获得一个块?
【发布时间】:2011-11-02 10:54:33
【问题描述】:

我正在尝试在主页上创建产品块,在其中我将 page.xml 复制到我的主题的布局文件夹并对其进行了修改

<page_two_columns_left translate="label">
<label>All Two-Column Layout Pages (Left Column)</label>
<reference name="root">
    <action method="setTemplate"><template>page/2columns-left.phtml</template></action>
    <!-- Mark root page block that template is applied -->
    <action method="setIsHandle"><applied>1</applied></action>
</reference>
<reference name="content">
   <block type="core/template" name="mycategories" output="toHtml" template="sweet/sweet.phtml"/>
 </reference>

在这里,我期待在我的主页中间有一个块,我得到了,但除此之外,我在主页底部又得到了一个块(与这个块 sweet.phtml 相同)..在页脚链接下方。谁能告诉我是什么问题。

【问题讨论】:

  • 你想用你的块替换一些名为mycategories的块吗?

标签: magento-1.4 magento-1.5 magento


【解决方案1】:

您已将块标记为输出块。当视图通过控制器操作中的renderView() 呈现时,您的块既是与其子代相呼应的块的子代(contentcore/text_list 块),也是输出块将被自己渲染。

删除output="toHtml" 位,您将拥有所需的内容。顺便说一句,您可以/应该将此更改从自定义 page.xml 移动到布局中的 local.xml 文件中 - 它只需要在 &lt;page_two_columns_left /&gt; 布局更新句柄内。

【讨论】:

  • 太好了,谢谢...我已将 page.xml 复制到我的文件夹中,但它已被覆盖。我只在那里进行更改。不好吗?
  • 嗯,它会干扰升级路径。理想情况下,此类更改将在主题布局文件夹中的 local.xml 文件中进行,您将 page.xml 保留在原处。因此,您的 local.xml 将包含 <...>
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-05-21
  • 1970-01-01
相关资源
最近更新 更多