0

By now, I have 'My account' (with its dropdown menu) next to 'Log in' in my home page.

I want to only have a 'Log in' button that changes to 'Log out' when user is logged.

I've been trying with local.xml but couldn't succeed. I know I should edit something there but can't find out what.

1

Copy customer.xml to your theme (if it's not there already). Then remove OR comment below line:

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

For changing Name/Title, you can update the values of above xml's <label> and <title> tags, like:

<action method="addLink" translate="label title" module="customer"><label>CUSTOM NAME</label><url helper="customer/getAccountUrl"/><title>CUSTOM NAME</title><prepare/><urlParams/><position>10</position></action>
  • You say the customer.xml from app/design/frontend/theme/default/layout? Because I'm uploading from FTP and see no change. It's really frustrating. – mangus May 19 '16 at 13:59
  • ys, copy customer.xml of your CURRENT THEME. Paste it here if possible – Anil Suthar May 19 '16 at 14:00
  • I could find the line: <default> <!-- Mage_Customer --> <reference name="top.links"> <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> </default> But nothing happens if I remove or comment the line and reupload it. – mangus May 19 '16 at 14:07
  • Why is commenting not working? – mangus May 19 '16 at 15:55
  • After commenting or removing, clear cache – Anil Suthar May 20 '16 at 5:00
0

You can get an idea that how you can edit top links in Magento 1, from below link:

http://www.webinse.com/blog/magento/top-links-in-magento-2/

However, below is code the code the to show login and logout link, depends on session:

 <?php if (Mage::helper('customer')->isLoggedIn() ): ?>
            <a href="<?php echo Mage::helper('customer')->getLogoutUrl(); ?>"><?php echo 'Logout'; ?></a>

        <?php 
    /*
    else: ?>
            <a href="<?php echo Mage::helper('customer')->getLoginUrl(); ?>">Login</a>
        <?php 
    */
    endif; ?>
  • Thanks, but maybe is more information that what I need. I'm trying to leave just one button 'Log In" that changes to 'Log out' when session is started. Is it too hard? I'm very new to Magento. Thanks in advance. – mangus May 19 '16 at 13:26
  • @mangus As I said, it is mentioned in the article. Kindly check it out. It is easy. And code which I shared, is the one you will be using. – Fayyaz Khattak May 19 '16 at 13:30
  • Where should I include the code for session? – mangus May 19 '16 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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