Magento Resource | E-Commerce Generation Explorer

Jun/09

22

Move mini-cart in the sidebar to the header (or anywhere)

Here is a solution for: How to move the cart sidebar into the header area or anywhere you want.

1) Copy the the block for the cart side bar:
\design\frontend\default\default\layout\checkout.xml

1
<block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml"/>


2) Open up app\design\frontend\default\default\layout\page.xml (for example, assuming you are using the default design)
Find the code :

1
<block type="page/html_header" name="header" as="header"> //near line 58

Within that block, you will see other sub-blocks.
Paste your new block in there. Add the “as” attribute and set it to “topcart” — final result:

1
2
3
4
5
6
7
<block type="page/html_header" name="header" as="header">
<block type="page/template_links" name="top.links" as="topLinks"/>
<block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>
<block type="core/text_list" name="top.menu" as="topMenu"/>
<!--add new block here-->
<block type="checkout/cart_sidebar" name="cart_sidebar" as="topcart" template="checkout/cart/sidebar.phtml"/>
</block>

3) Finally, go into app\design\frontend\default\default\template\page\html\header.phtml (again, assuming your using default theme) and add the codes:

1
2
//place this where ever you want the cart to show up.
<?php echo $this->getChildHtml('topcart'); ?>

Something need to know:
Removing the cart in a CMS page would also be handy to know:
In the Update Layout XML area, use:
You might have to wrap this in (name changing dependent on your design/template)

1
<action method="unsetChild"><name>cart_sidebar</name></action>

No tags

5 comments

  • jarnail · 04/02/2010 at 16:12

    I am displaying cart box with getChildHtml(‘topcart’); ?> in 2 different places. The issues is that I need to display different color for both not similar, but it is coming from getChildHtml(‘topcart’); ?>. How can I do that. Please help.

    thanks in advance

  • Admin comment by admin · 14/03/2010 at 03:10

    You can create anothe file as topcart2, also modifty the XML file to call the topcart2 (same copy all the things you said as getChildHtml(‘topCart2’)), hope helpful

  • krite · 20/08/2010 at 15:08

    2 Problem
    1. I paragraph not understand
    Removing the cart in a CMS page would also be handy to know:
    In the Update Layout XML area, use:
    You might have to wrap this in (name changing dependent on your design/template)

    ?View Code XML
    1
    cart_sidebar

    Remark : I follow one of the three, but do not understand any of this cart_sidebar where it should go at now my cart sidebar from the side. left up to the header covered with mini Search and toplink but I want to format 0 Items: $ 0.00 near the checkout do not know how instructions should resolve with thanks.

  • krite · 20/08/2010 at 15:09

    [code]cart_sidebar[code] I am not understand

  • Shahzad Jameel · 15/04/2011 at 12:56

    Hi,

    When i did the above changes i got a complete white page instead of my default template. What i did wrong?

    Thanks

Leave a Reply

<<

>>

Theme Design by devolux.nh2.me