简体   繁体   English

我在Magento两次拦截?

[英]I am getting a block twice in Magento?

I am trying to create product block on home page where in I copied page.xml to my theme's layout folder and modified it like 我正在尝试在主页上创建产品块,在那里我将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>

Here I was expecting one one block in the middle of my Home page and i am getting that but in addition to this i am getting one more block (same as this block sweet.phtml) at the bottom of home page.. below the footer link. 在这里,我期待在我的主页中间有一个块,我得到了但除此之外我在主页的底部还有一个块(与此块sweet.phtml相同)。页脚下方链接。 Can anyone tell me whats the problem. 任何人都可以告诉我这是什么问题。

You've marked your block as an output block. 您已将块标记为输出块。 When the view is rendered via renderView() in the controller action, your block is both a child of a block which echoes its children ( content is a core/text_list block), as well as being an output block which will be rendered in its own right. 当视图通过控制器动作中的renderView()呈现renderView() ,您的块既是块的子core/text_list ,它回显其子core/text_list内容core/text_list块),也是一个将在其中呈现的输出块。自己的权利。

Remove the output="toHtml" bit and you will have what you need. 删除output="toHtml"位,您将拥有所需的内容。 By the way, you could / should move this change from a custom page.xml and into a local.xml file in your layout - it need only be inside a <page_two_columns_left /> layout update handle. 顺便说一下,您可以/应该将此更改从自定义page.xml移动到布局中的local.xml文件中 - 它只需要在<page_two_columns_left />布局更新句柄中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM