Do I get a block twice in Magento?

I am trying to create a product block on the home page where I copied page.xml to the theme layout folder and changed it as

<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 block in the middle of my home page, and I get this, but in addition to this, I get another block (the same as this sweet.phtml block) at the bottom of the home page. below the footer. Can anyone tell me what the problem is.

+7
source share
1 answer

You marked your block as an output block. When a view is displayed using renderView() in a controller action, your block is a child of the block that echoes its children (the content is a core/text_list ), and it is also an output block that will be displayed in its own right.

Remove the output="toHtml" bit and you will have what you need. By the way, you could / should transfer this change from the user page.xml and to the local.xml file in your layout - this is only necessary inside the layout update descriptor <page_two_columns_left /> .

+12
source

All Articles