[英]How to conditionally remove top home link via local.xml in Magento 1.5.1
[英]Removing top.links url then re-adding link with custom label via local.xml
我试图删除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"
添加新链接。
解:
我从/ app / design / frontend / base / layout /复制了customer.xml到我的模板布局目录中,并添加了:
<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进行这些更改,但这也可以。
看来您不需要将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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.