问题描述
我试图在主页上创建产品块,在该产品中,我将page.xml复制到主题的布局文件夹中,并进行了修改
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_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块相同).页脚链接下方.谁能告诉我是什么问题.
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. Can anyone tell me whats the problem.
推荐答案
您已将您的代码块标记为输出代码块.当在控制器动作中通过renderView()
渲染视图时,您的块既是回显其子级的块的子级( content 是core/text_list
块),又是输出区块将以其自身的权利呈现.
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.
删除output="toHtml"
位,您将拥有所需的内容.顺便说一句,您可以/应该将此更改从自定义page.xml移动到布局中的local.xml文件中-它只需要位于<page_two_columns_left />
布局更新句柄之内即可.
Remove the output="toHtml"
bit and you will have what you need. 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.
这篇关于我在Magento中遇到两次障碍了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!