Magento - Moving Cart_sidebar to top.phtml

I am looking to move cart_sidebar to top.phtml. This is a fairly simple step that I have taken several times, however I am now lucky that I am running Magento 1.5.1.

did they mean something?

see code used below.

checkout.xml

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

page.xml

<block type="page/html_header" name="header" as="header">
    <block type="checkout/cart_sidebar" name="mini_cart_top" as="mini_cart_top" template="checkout/cart/sidebar.phtml"/>
other misc code...

top.phtml

<?php echo $this->getChildHtml('mini_cart_top'); ?>

Any help would be greatly appreciated!

catalog.xml

<reference name="top.menu">
            <block type="catalog/navigation" name="catalog.topnav" template="catalog/navigation/top.phtml"/>
            <block type="checkout/cart_sidebar" name="mini_cart_top" as="mini_cart_top" template="checkout/cart/sidebar.phtml"/>

        </reference>
+3
source share
3 answers

I successfully moved this to 1.5

You have placed the cart_sidebar XML block in the header block, which allows you to use it in header.phtml and not top.phtml.

top.phtml is a similar block for sidebar.phtml - it should contain only a navigation category, not a basket.

If you can specify where you want to place it and why, I will tell you how to make it work.

+4

- , , jQuery Technooze.
jquery (. )

( , , ). , ( Checkout, My Account My Cart links) , , Checkout.xml sidebar_cart .
Checkout.xml:

<reference name="top.links">
        <block type="checkout/links" name="checkout_cart_link">
            <!-- erase cart link:
            <action method="addCartLink"></action> -->
            <!-- I also erase Checkout link - no point for me: 
            <action method="addCheckoutLink"></action>-->
            <!--and we include the sidebar_cart block into page/template/links-->
            <block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml" before="-">
                <action method="addItemRender"><type>simple</type><block>checkout/cart_item_renderer</block><template>checkout/cart/sidebar/default.phtml</template></action>
                <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/cart/sidebar/default.phtml</template></action>
                <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/cart/sidebar/default.phtml</template></action>
                <block type="core/text_list" name="cart_sidebar.extra_actions" as="extra_actions" translate="label" module="checkout">
                    <label>Shopping Cart Sidebar Extra Actions</label>
                </block>
            </block>
        </block>
    </reference>

, "header".

page.xml , :

<block type="page/template_links" name="top.links" as="topLinks">
        <!-- include sidebar cart -->
            <block type="checkout/cart_sidebar" name="cart_sidebar" as="topcart" template="checkout/cart/sidebar.phtml"/>
        <!-- close block here -->
        </block>
        <block type="page/html_breadcrumbs" name="breadcrumbs" as="breadcrumbs"/>

cart_sidebar /page/template/links.phtml .

<?php echo $this->getChildHtml('topcart'); ?>

- .

+1

Moving the mini cart to the header in magento is really easy, you just need to change your xml and you are done with it. Below are the steps by which we can move the mini basket.

Step1. Open checkout.xml from location given below

/design/frontend/default/[your theme]/layout/checkout.xml

find the code below in file.

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

Step2. now open page.xml can be found in the location below

\design\frontend\default\[your theme]\layout\page.xml

in this file find the code given below

<block type="page/html_header" name="header" as="header">

paste the the cart_sidebar block as shown below.

<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" translate="label">
    <label>Navigation Bar</label>

    <!--new added block -->
<block type="checkout/cart_sidebar" name="cart_sidebar" template="checkout/cart/sidebar.phtml"/>
    <!--end new block -->
    <block type="page/html_topmenu" name="catalog.topnav" template="page/html/topmenu.phtml"/>
</block>

Clear the cache.

0
source