1

I have a custom module in my magento store. It is currently using the default 2 column layout with magento's left nav as the lefthand sidebar.

How can i go about having the customer account navigation in my left sidebar instead? My current xml file for my module is:

earnings.xml

<?xml version="1.0"?>
<layout version="0.1.0">
    <earnings_index_index>
        <reference name="content">
            <block type="earnings/earnings" name="earnings" />
        </reference>
    </earnings_index_index>
</layout>

3 Answers 3

4

You just need to use the XML function

<earnings_index_index translate="label">
    <update handle="customer_account"/>
    <reference name="my.account.wrapper">
        <block type="core/template" name="earnings" template="earnings/earnings.phtml" />
    </reference>
</earnings_index_index>

To change the default title within your controller you'll need to place

$this->getLayout()->getBlock('head')->setTitle($this->__('Title here'));

Withing your loadLayout() and renderLayout() calls, such as:

$this->loadLayout()
$this->getLayout()->getBlock('head')->setTitle($this->__('Title here'));
$this->renderLayout();
5
  • Thanks Dave but when i do the above my earnings page now shows the account navigation but not the earnings.phtml. Turning on template path hints shows the phtml file is not being shown/loaded
    – odd_duck
    Commented Aug 19, 2014 at 15:48
  • @odd_duck does your block earnings/earnings contain a setTemplate call?
    – Dave
    Commented Aug 19, 2014 at 16:30
  • Had another look at this and managed to get it working by changing the block type to <block type="core/template" name="earnings" template="earnings/earnings.phtml" /> instead so probably what you were mentioning? Thank you so much. One last thing - how would i go about setting the page title for this page in the above?
    – odd_duck
    Commented Aug 20, 2014 at 8:41
  • @odd_duck I've updated my original answer with how to change the title.
    – Dave
    Commented Aug 20, 2014 at 8:45
  • @odd_duck no problem!
    – Dave
    Commented Aug 20, 2014 at 10:05
0

Below are the snippet on adding link to left navigation in my account section.

<customer_account translate="label">        
            <reference name="customer_account_navigation">
                <action method="addLink" translate="label"><name>nameoflink</name><path>path/index/index/</path><label>Custom Account Link</label></action>
            </reference>
        </customer_account>
2
  • I don't want to add a link to the navigation, i want to add the navigation to a page
    – odd_duck
    Commented Aug 19, 2014 at 15:47
  • please check what you have asked. i think you have not specified in the question. Commented Aug 19, 2014 at 15:50
0

You can set a page layout using root block. Here is the code that you need to try

<earnings_index_index>
        <reference name="root">
            <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
        </reference>
         <reference name="content">
             <!-- put content blocks here -->
         </reference>
</earnings_index_index>

Take a look on the section root block. This block is use to set layout template that need to use while render the page. Here it is set to 2columns-right.phtml. This template allow navigation section in the right side. Take a look at app/design/frontend/<pockage>/<theme>/template/page/ directory. There you can see page layout template files that are use to constitute the page structure. You can use any of those layout files by specifying there name in root block.

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.