Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento 1.7*: How do I add "Logout"-link in the sidebar, of my-account-page

I would like to add a "logout" link to a Magento shop, that i am developing.

In the page "My account", left sidebar under all the links (last link at the bottom):

  • Account Dashboard
  • Account information
  • Adress book
  • Etc.

How do I add a link at the bottom?

I think that I should add a line of code in customer.xml.

I guess it should be in this block:

        <block type="customer/account_navigation" name="customer_account_navigation" before="-" template="customer/account/navigation.phtml">
            <action method="addLink" translate="label" module="customer"><name>account</name><path>customer/account/</path><label>Account Dashboard</label></action>
            <action method="addLink" translate="label" module="customer"><name>account_edit</name><path>customer/account/edit/</path><label>Account Information</label></action>
            <action method="addLink" translate="label" module="customer"><name>address_book</name><path>customer/address/</path><label>Address Book</label></action>
        </block>

And something in the line of:

<action method="addLink" translate="label" module="customer"><name>LOGOUT</name><path>LOGOUT_PATH</path><label>Logout</label></action>

I'm just not sure what the exact code should be.

Thanks in advance for any help

like image 788
Hans Preutz Avatar asked Dec 26 '22 22:12

Hans Preutz


1 Answers

While your solution works, it is considered best practice to make all layout changes within the file app/design/frontend/your_package/your_theme/layout/local.xml and refrain from editing the other layout files directly.

For this change, your local.xml would look like:

<?xml version="1.0"?>

<layout version="0.1.0">

    <customer_account>

        <reference name="left">

            <reference name="customer_account_navigation">
                <action method="addLink" translate="label" module="customer">
                    <name>logout</name>
                    <path>customer/account/logout/</path>
                    <label>Log Out</label>
                </action>
            </reference>

        </reference>

    </customer_account>

</layout>

local.xml Reference

A good resource to start using local.xml is on this page:
Classy Llama's Better Way to Modify Magento Layout

Article would be better without the word wrapping but they cover most of the means of editing your layout.

like image 50
Jason Avatar answered Apr 26 '23 20:04

Jason