1

copy file of sidebar.phtml file in path app\design\frontend\base\default\template\checkout\cart paste in mytheme name is cart_top.phtml path is mythmeme\template\checkout\cart add the code in my header.phtml file. <?php echo $this->getLayout()->createBlock('checkout/cart_sidebar')->setTemplate('checkout/cart/cart_top.phtml')->toHtml()."Mycart"; ?> add this code in my header.phtml but block is not working. can you tell me what the issue?

2
  • which magento version are you using?
    – Amit Bera
    Commented Sep 3, 2014 at 5:50
  • Magento ver. 1.8.1.0 using
    – coder
    Commented Sep 3, 2014 at 5:51

1 Answer 1

1

Jaydipsinh Parmar you can do using xml

create local.xml at app/design/frontend/your_package/our_theme/layout/ and past the code

       <default>

   <reference name="header">

        <block type="checkout/cart_sidebar" name="cart_sidebar_header" template="checkout/cart/cart_top.phtml" >
                <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>
 </reference>    </default>

then add the echo $this->getChildHtml('cart_sidebar_header') to header.phtml

8
  • but i want call my custom template cart_top.phtml then what you doing?
    – coder
    Commented Sep 3, 2014 at 6:03
  • also i add this in my local.xml file call in header.phtml file but not working.
    – coder
    Commented Sep 3, 2014 at 6:05
  • hey are you want change just sideber template file or call sidebar bar on header
    – Amit Bera
    Commented Sep 3, 2014 at 6:22
  • if you want to call sidebar on header... then you can try my code.. i have missing <default>
    – Amit Bera
    Commented Sep 3, 2014 at 6:26
  • remove cart sidebar in sidebar i do code <remove name="cart_sidebar"></remove> in local.xml file it can be issue with your code that's not working
    – coder
    Commented Sep 3, 2014 at 6:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.