我正在尝试删除top.links中的我的帐户链接,然后在客户使用自定义标签登录或注销时重新引入它们。任何人有任何想法
<reference name="root">
<reference name="top.links">
<action method="removeLinkByUrl"><url helper="customer/getAccountUrl"/><position>10</position></action>
</reference>
<reference name="top.links">
<customer_logged_out>
<action method="addLink" translate="label title" module="customer"><label>Register</label><url helper="customer/getRegisterUrl"/><title>Register</title><prepare/><urlParams/><position>10</position></action>
<remove name="checkout_cart_link" />
</customer_logged_out>
<customer_logged_in>
<action method="addLink" translate="label title" module="customer"><label>My Account</label><url helper="customer/getAccountUrl"/><title>My Account</title><prepare/><urlParams/><position>10</position></action>
</customer_logged_in>
</reference>
</reference>
编辑:
我正在使用Magento 1.7。为了澄清,删除“我的帐户”链接可以使用
<action method="removeLinkByUrl"><url helper="customer/getAccountUrl"/><position>10</position></action>
但是我无法使用method="addLink"
添加新链接。
解决方案:
我将customer.xml从/ app / design / frontend / base / layout /复制到我的模板布局目录中并添加:
<customer_logged_in>
<reference name="top.links">
<action method="addLink" translate="label title" module="customer"><label>Log Out</label><url helper="customer/getLogoutUrl"/><title>Log Out</title><prepare/><urlParams/><position>100</position></action>
<action method="addLink" translate="label title" module="customer"><label>My Account</label><url helper="customer/getAccountUrl"/><title>My Account</title><prepare/><urlParams/><position>10</position></action>
</reference>
</customer_logged_in>
和
<customer_logged_out>
<reference name="top.links">
<action method="addLink" translate="label title" module="customer"><label>Register</label><url helper="customer/getRegisterUrl"/><title>Register</title><prepare/><urlParams/><position>10</position></action>
</reference>
</customer_logged_out>
理想情况下,我更喜欢使用local.xml来进行这些更改,但这也有效。
答案 0 :(得分:0)
您似乎不需要将customer_logged_in节点放在“top.links”引用中。试试这个:
<customer_logged_out>
<reference name="top.links">
<action method="addLink" translate="label title" module="customer"><label>Register</label><url helper="customer/getRegisterUrl"/><title>Register</title><prepare/><urlParams/><position>10</position></action>
<remove name="checkout_cart_link" />
</reference>
</customer_logged_out>
<customer_logged_in>
<reference name="top.links">
<action method="addLink" translate="label title" module="customer"><label>Log Out</label><url helper="customer/getLogoutUrl"/><title>Log Out</title><prepare/><urlParams/><position>10</position></action>
</reference>
</customer_logged_in>
并查看这本精美的手册,以全面了解如何编辑local.xml中的top.links: http://www.classyllama.com/development/magento-development/editing-magentos-top-links-the-better-way