我正在开发一个基于Magento侧边栏购物车功能的下拉购物车。多亏了一个教程,我在编辑checkout.xml和page.xml文件时做到了这一点,但我想通过编辑我的local.xml文件来实现真正的Magento方式。这是我的代码:
header.phtml
div class="top-cart">
<?php echo $this->getChildHtml('topCart') ?>
<div class="top-cart-menu">
<?php echo $this->getChildHtml('topCartBlock') ?>
</div>
</div>
local.xml
<block type="checkout/cart_sidebar" name="cart_sidebar" as="topCartBlock" 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>
<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>
到目前为止,它还在工作,我在标题中显示了侧边栏迷你购物车。但是为了实现mouseover,我需要cart链接。当我把上面的代码和下面的代码放在page.xml中时,它可以工作,但当我把它添加到local.xml中时就不会显示链接了。
<reference name="top.cart">
<action method="addLink" translate="label title">
<label>Your Cart</label>
<url>checkout/cart</url>
<title>Your cart</title>
<position>1</position>
<li/>
<a>id="top-link-cart"</a>
</action>
</reference>
我必须如何修改此代码才能获得"我的购物车"链接?
我用替换了最后一段代码
<block type="page/template_links" name="topCart" as="topCart">
<block type="checkout/links" name="cart_link">
<action method="addCartLink">
</action>
</block>
</block>
这为我们提供了购物车的链接,我将使用它作为鼠标悬停链接