在Magento 1.6.2中登录/注销时如何从top.liknks中删除链接 [英] How to remove links from top.liknks when loggin in / out in Magento 1.6.2

查看:63
本文介绍了在Magento 1.6.2中登录/注销时如何从top.liknks中删除链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在搜索,找到了customer_logged_incustomer_logged_out标签,但是我无法使它们正常工作,这肯定是我对它们的误解.

I've had a good search around and found the customer_logged_in and customer_logged_out tags but I can't get them to work properly, this I'm sure is down to my misunderstanding of them.

我的目标是在用户不是登录时,从块top.links隐藏登录,帐户和结帐链接,并在用户时显示它们登录.

My goal is to hide the log in, account and checkout links from the block top.links when the user is not logged in and show them when the user is logged in.

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

I have placed the following at the end of my local.xml file to try and remove the log in link:

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

</default>

但是它不起作用.有人可以解释为什么这行不通吗?这让我发疯了!

But it does not work. Can someone please explain why this does not work? It's driving me crazy!

推荐答案

好吧,我找到了原因,首先它们是顶级标签,不应放在默认标签中,其次它在local.xml,所以我将代码放置在customer.xml的顶部,并且可以使用.注意:我删除了xml,该xml添加了指向top.links的链接,这似乎会干扰它.

Ok I found the reason, first off they are top level tags and shouldn't be put in the default tag and secondly it just wasn't working in the local.xml so I placed the code at the top of the customer.xml and it works a treat. Note: I removed the xml which added links to the top.links as well as this seems to interfere with it.

工作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>

这篇关于在Magento 1.6.2中登录/注销时如何从top.liknks中删除链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆