6

I have tried to show the Customer Navigation menu in Custom template file.

Below is My Code:

<div id="customer_menu">
<?php echo $this->getLayout()->createBlock('customer/account_navigation')->setTemplate('customer/account/navigation.phtml')->toHtml();?>
</div>

The menu is not loading well. Showing like below image

enter image description here

Any suggestions will be appreciated.

Thanks,

9
  • Have you tried to add the customer menu via the layout handle?
    – Amasty
    Commented Aug 13, 2014 at 12:22
  • @Amasty No, I tried via phtml file.
    – VijayS91
    Commented Aug 13, 2014 at 12:29
  • are you want to show in special page???
    – Amit Bera
    Commented Aug 13, 2014 at 12:44
  • @AmitBera yes, i tried to show in Popup
    – VijayS91
    Commented Aug 13, 2014 at 12:46
  • is pop is coming for which page or all page??
    – Amit Bera
    Commented Aug 13, 2014 at 12:48

3 Answers 3

5

The result you are getting is normal. The block with alias customer/account_navigation does not actually contain the customer account links.
It acts only as a container where other layout files / modules can add links.
If you use a new instance of the block this one will not contain any links.
What I suggest is to add the following code to the layout handle of your page:

<update handle="customer_account" />

This will automatically load the layout directives for the customer account, including the navigation links.
You won't even need to add any html. The block will be displayed on the left sidebar.

1
0

Hi can you try of below code

add a event

<frontend>

<events>
            <controller_action_layout_load_before>
                <observers>
                    <mymodule>
                        <class>mymodulemodel/observer</class>
                        <method>beforeLoadLayout</method>
                    </mymodule>
                </observers>
            </controller_action_layout_load_before>
         <events>
</frontend>

and observer code

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

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

And it is show in all page Where left panel is exist in layout

If you want to show

in call page then create new layout

   <customer_account_custom translate="label">
        <label>Customer My Account (All Pages)</label>
       <reference name="yourlayoutreferce">
            <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>
        </reference>
    </customer_account_custom>

and change in

observer  $observer->getEvent()->getLayout()->getUpdate()
       ->addHandle('customer_account_custom');
0

You can add link to your module in the same way as default reviews module does:

<customer_account>
    <!-- Mage_Review -->
    <reference name="customer_account_navigation">
        <action method="addLink" translate="label" module="review"><name>reviews</name><path>review/customer</path><label>My Product Reviews</label></action>
    </reference>
</customer_account>

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.