-1

We have added the customer account links in manually with our local.xml file like so:

<reference name="right">
        <block type="customer/account_navigation" name="customer_account_navigation" after="-" template="customer/account/navigation.phtml">
            <action method="addLink" translate="label" module="customer">
                <name>account</name>
                <path>customer/account/</path>
                <label>My Account</label>
            </action>
         </block>
</reference>

I now need to be able to get this list of links in the header template. I have create a block like so:

<block name="header.topbar.account" as="header-topbar-account" type="customer/account_navigation" template="johnsmedleytheme/page/header/topbar/account.phtml"/>

Wrapped in the header reference tag. and in my phtml i am currently calling:

$this->getLinks();

In order to retrieve the customer account nav links. But the array is returning empty.

Any ideas?

Cheers

7
  • are you want to show account link on header
    – Amit Bera
    Commented Aug 29, 2014 at 15:33
  • Yes there will be an if to see if user is logged in or not etc and if they are we want to show some of the account links
    – Tom Burman
    Commented Aug 29, 2014 at 15:37
  • your template is adding correctly in layout ? Commented Aug 29, 2014 at 15:40
  • @Marius : I was unaware of this. So i delete my answer. Thanks for that great insight Commented Aug 29, 2014 at 15:46
  • that means......only logged in customer will see the link?
    – Amit Bera
    Commented Aug 29, 2014 at 15:48

1 Answer 1

1

1)create new layout in default.

    <customer_logged_tops>
 <reference name="mytoplinks">
        <block type="customer/account_navigation" name="customer_account_navigation" 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>
</reference>    
</customer_logged_tops>

2)create an event on controller_action_layout_load_before.

<frontend>
    <events>
        <controller_action_layout_load_before>
            <observers>
                <customer_is_logged_in_newlayout>
                    <class>youmodule/observer</class>
                    <method>beforeLoadLayout</method>
                </customer_is_logged_in_observer>
            </observers>
        </customer_is_logged_in_newlayout>
    </events>
</frontend>

3) update this using event.

 public function beforeLoadLayout($observer)
    {
        $loggedIn = Mage::getSingleton('customer/session')->isLoggedIn();

        $observer->getEvent()->getLayout()->getUpdate()
           ->addHandle('customer_logged_tops');
    }

4)just define on local.xml

<default>
    <reference name="header">
    <block type="core/template" name="mytoplinks" as="mytoplinks"/>
    </reference>
 </default>
4
  • it not test.. totally on concept...
    – Amit Bera
    Commented Aug 29, 2014 at 15:58
  • This is totally new concept for me !. If this works, this would be a great answer. Commented Aug 29, 2014 at 16:02
  • plus there is a small error that lyes inside layout file. You forgot to put reference name="header" /> node Commented Aug 29, 2014 at 16:03
  • Cheers for the answer, this may be a last resort test! But right now can you see any issues with what i have done above? And why it may not be working the way i expected it too? Cheers
    – Tom Burman
    Commented Sep 1, 2014 at 7:54

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.