English 中文(简体)
Magento 1. 6. 2 登录/ 退出时, 如何从顶部. liknks 中删除链接 。
原标题:How to remove links from top.liknks when loggin in / out in Magento 1.6.2

我在周围进行了良好的搜索,发现了 customer_logged_ in customer_logged_out 标签,但我无法让他们正常工作,我肯定我对他们有误解。

我的目标是在用户 not 登录时,将日志从块 top.links 中隐藏、账户和校验链接,并在用户 登录时显示这些链接。

我在我的 local.xml 文件末尾放置了以下内容, 以尝试并删除链接的日志 :

    <customer_logged_in>
        <reference name="top.links">
            <action method="removeLinkByUrl"><url helper="customer/getLoginUrl"/></action>
        </reference>
    </customer_logged_in>

</default>

谁能解释一下为什么不行吗?

最佳回答

OK 我找到了原因, 首先它们是顶级标签, 不应该被放在默认标签中, 其次它只是没有在本地. xml 工作, 所以我把代码放在客户的顶部, xml 起作用了。 注意: 我删除了在顶部添加链接的 xml 。 链接和这似乎干扰了它 。

工作xml :

<!--
Load this update on every page when customer is logged in
-->

    <customer_logged_in>
        <reference name="top.links">
            <action method="addLink" translate="label title" module="checkout"><label>My Cart</label><url helper="checkout/cart/getCartUrl"/><title>My Cart</title><prepare/><urlParams/><position>9</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>
            <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>
        </reference>
    </customer_logged_in>

<!--
Load this update on every page when customer is logged out
-->
    <customer_logged_out>
        <reference name="top.links">
            <action method="addLink" translate="label title" module="customer"><label>Sign up</label><url helper="customer/getRegisterUrl"/><title>Register </title><prepare/><urlParams/><position>100</position></action>
            <action method="addLink" translate="label title" module="customer"><label>Log In</label><url helper="customer/getLoginUrl"/><title>Log In</title><prepare/><urlParams/><position>100</position></action>
            <action method="removeLinkByUrl"><url helper="checkout/url/getCheckoutUrl"/></action>
            <action method="removeLinkByUrl"><url helper="checkout/cart/getCartUrl"/></action>         
            <action method="removeLinkByUrl"><url helper="customer/getLogoutUrl"/></action>
        </reference>
    </customer_logged_out>
问题回答

移除本地. xml 的链接在我的案例中有效。 以下是代码 :

<customer_logged_in>
    <reference name="top.links">
        <action method="removeLinkByUrl"><url helper="customer/getLogoutUrl"/></action>
    </reference>
</customer_logged_in>
<customer_logged_out>
    <reference name="top.links">
        <action method="removeLinkByUrl"><url helper="customer/getLoginUrl"/></action>
    </reference>
</customer_logged_out>




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Remotely authenticating client Windows user on demand

Suppose I am writing a server for a particular network protocol. If I know that the client is running on a Windows machine, is it possible for my server to authenticate the Windows user that owns the ...

Role/Permission based forms authorizing/authentication?

While looking into forms authorizing/authentication, I found that it is possible to do role based authorizing by adding an array of roles to a FormsAuthenticationTicket. That way I can write User....