Question

I am new to magento. I created a block to place this block in all pages, but this is showing double time in home page.

below is my code

//local.xml

</block> </reference> </catalog_catagory_default> -->

<page_one_column translate="label">
    <reference name="right">
        <block name="mtb.template" type="core/template" template="page/mtb/mytemplate.phtml"></block>
    </reference>
</page_one_column>

<page_empty translate="label">
    <reference name="right">
        <block name="mtb.template" type="core/template" template="page/mtb/mytemplate.phtml"></block>
    </reference>
</page_empty>

<page_three_columns translate="label">
    <reference name="right">
        <block name="mtb.template" type="core/template" template="page/mtb/mytemplate.phtml"></block>
    </reference>
</page_three_columns >

<page_two_columns_left translate="label" >
    <reference name="right">
        <block name="mtb.template" type="core/template" template="page/mtb/mytemplate.phtml"></block>
    </reference>
</page_two_columns_left>

and //catalog.xml

<reference name="left">
            <block name="mtb.template" type="core/template" template="page/mtb/mytemplate.phtml"></block>
</reference>

<reference name="right">
          <block name="mtb.template" type="core/template" template="page/mtb/mytemplate.phtml"></block>
</reference>

my block is

enter image description here

can any one tell me where i went wrong?

if my block show in all pages what I can do?

thanks in advance.

Was it helpful?

Solution

All you need to do is add this to only one of your layout files.

<default>
    <reference name="left">
        <block name="mtb.template.left" type="core/template" template="page/mtb/mytemplate.phtml" />
    </reference>
    <reference name="right">
        <block name="mtb.template.right" type="core/template" template="page/mtb/mytemplate.phtml" />
    </reference>
</default>

But in case you have a page with the layout 3columns the block will appear bot on the left and right column. For that you need to remove one of them. You can do it like this.

<page_three_columns translate="label">
    <remove name="mtb.template.right" /><!-- or "mtb.template.left"-->
</page_three_columns>

To remove it from a page do this:

<catalog_category_view>
    <remove name="mtb.template.right" /><!-- or "mtb.template.left"-->
</catalog_category_view>
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top