How to remove links from top.liknks when loggin in / out in Magento 1.6.2

后端 未结 2 1498
夕颜
夕颜 2021-01-06 23:59

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

相关标签:
2条回答
  • 2021-01-07 00:38

    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.

    Working 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>
    
    0 讨论(0)
  • 2021-01-07 00:54

    Removing links in local.xml works in my case. Here is the code:

    <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>
    
    0 讨论(0)
提交回复
热议问题