【发布时间】:2012-02-10 20:54:55
【问题描述】:
我正在开发基于 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>
到目前为止,它正在工作,我的标题中显示了侧边栏迷你购物车。但为了实现鼠标悬停,我需要购物车链接。当我将上面的代码和以下代码放在 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>
如何修改此代码才能获得“我的购物车”链接?
【问题讨论】:
-
如果您找到有效的解决方案,您可以创建自己的答案并接受它。
-
一旦您接受了答案(通过单击对勾),就无需用 [solved] 标记标题。
标签: php xml magento shopping-cart cart