当前位置: 动力学知识库 > 问答 > 编程问答 >

Adding Cart to top.menu in Magento

问题描述:

I'm busy building a navigation bar that includes the user menu and cart along with the wishlist but trying to figure out how one would add it in the xml mockup to include it using the getChildHtml function.

I'm still very new to magento so please bare with me.

XML file: page.xml

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

I've got

<block type="core/text_list" name="top.menu" as="topMenu" translate="label">

Now as far as I can see I have to include the following somewhere or extend the block or something not really sure, please help me in the right direction or even point me to a developers guide that would cover this.

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

Thank you.

网友答案:

Create a file local.xml in your theme folder app/design/frontend/your_package/your_theme/layout/ add the following lines and save the file.

<layout version="0.1.0">
    <default>
        <reference name="top.menu">
            <block type="checkout/cart_sidebar" name="cart_sidebar" as="topcart" template="checkout/cart/sidebar.phtml"/>
        </reference>
 </default></layout>

Don't forget to clear magento cache(System->Cache management) after applying the change.

In order to learn more about Magento blocks ,layouts ,templates there is an official magento guide check it here

分享给朋友:
您可能感兴趣的文章:
随机阅读: