2

我正在尝试删除 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 进行这些更改,但这也有效。

4

1 回答 1

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

于 2012-10-16T03:04:00.157 回答