0

I can't seem to get Magento to react to the customer_logged_in or customer_logged_out tags in local.xml

The LogOut link does not display unless I remove the customer_logged_in tag then the link displays and works correctly. I would like it to only show when the customer is logged in.

    <reference name="header">
        <block type="page/template_links" name="top.links2" as="topLinks"/>         
    </reference>

    <reference name="top.links2">
        <block type="checkout/links" name="checkout_cart_link">
            <action method="addCartLink"></action>
        </block>
    </reference>

    <customer_logged_in>
    <reference name="top.links2">
        <action method="addLink" translate="label title" module="customer">
            <label>Log Out</label>
            <url helper="customer/getLogoutUrl"/>
            <title>Log Out</title>
            <prepare/>
            <urlParams/>
            <position>4</position>
            <liParams>id="top-logout"</liParams>
            <aParams/>
        </action>
    </reference>
    </customer_logged_in>

1 Answer 1

1

Aw It appears I was not adding the action block in the correct layout node handle. I had the customer-logged-in and customer-logged-out nested under default.

Pulling them out of the default scope fixed the issue. This code works:

<default>
<reference name="header">
    <block type="page/template_links" name="top.links2" as="topLinks"/>         
</reference>

<reference name="top.links2">
    <block type="checkout/links" name="checkout_cart_link">
        <action method="addCartLink"></action>
    </block>
</reference>
</default>

<customer_logged_in>
<reference name="top.links2">
    <action method="addLink" translate="label title" module="customer">
        <label>Log Out</label>
        <url helper="customer/getLogoutUrl"/>
        <title>Log Out</title>
        <prepare/>
        <urlParams/>
        <position>4</position>
        <liParams>id="top-logout"</liParams>
        <aParams/>
    </action>
</reference>
</customer_logged_in>

A reference for others: http://magebase.com/magento-tutorials/5-useful-tricks-for-your-magento-local-xml/

1
  • I can't get this to work. I pasted it into the local.xml for my theme but it wont add that link.
    – HippoDuck
    Commented Jul 28, 2018 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.