How to remove the side bar cart from all pages but keep on product listing page in magento using local.xml

StackOverflow https://stackoverflow.com/questions/23469849

  •  15-07-2023
  •  | 
  •  

I have following code in local.xml

 <default>      
        <remove name="cart_sidebar" />
</default>

To remove the sidebar cart from all pages but I want to keep it on product listing page and product details page.

How can I do this?

有帮助吗?

解决方案

To achieve this you need to use Unset / Remove method.

To move a child block from one parent to another, reference the direct parent, call unsetChild on it, and then use the insert/add block method to assign the block instance as child to a different parent.

Try below code in your local.xml

    <?xml version="1.0" encoding="UTF-8"?>

<layout version="0.1.0">
<default>      

        <reference name="right">   
        <action method="unsetChild"><name>cart_sidebar</name></action>
        </reference>
</default>

<!--If you are not using layered navigation code start -->
<catalog_category_default>
    <reference name="right">
    <action method="insert"><block>cart_sidebar</block></action>
    </reference>
</catalog_category_default>
<!--If you are not using layered navigation code end -->


<!--If you are using layered navigation code start -->
<catalog_category_layered>
<reference name="right">
    <action method="insert"><block>cart_sidebar</block></action>
    </reference>
</catalog_category_layered>
<!--If you are using layered navigation code end -->

<catalog_product_view>
<reference name="right">
    <action method="insert"><block>cart_sidebar</block></action>
    </reference>
</catalog_product_view>

</layout>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top