Magento 1.7 – Adding Template File in Customer Account Page

blocksmagento-1.7template

I am adding one phtml file in customer account dashboard index page. I have used the code as

<customer_account_index>
    <reference name="customer_account_dashboard">
      <block type="ecustomers/myphtml" name="myphtml_page"  after="customer_account_dashboard_hello" template="ecustomers/myphtml.phtml" />
    </reference>
</customer_account_index>

And I want to show the phtml after the hello.phtml in user dashboard.

If I use <reference name="content"> handle then it shows my phtml content but if I use <reference name="customer_account_dashboard"> handle it does not show the my phtml file.

I think we can use the reference for the block which we want to update as I want to update the customer_account_dashboard so I referenced it. Please let me know if I am wrong in here.

Best Answer

There is nothing wrong with your xml, apart from the fact that the before="" will have no function here.

The issue is that dashboard block is not a core text list type of block. Thus the phtml that deals with the dashboard display will not 'magically' output your block.

You need to add an entry to the dashboard.phtml file to echo out your block.

<?php echo $this->getChildHtml('myphtml_page') ?>

and place that in the correct position above the code the outputs the hello block

Naturally you will copy the dashboard.phtml file to your theme to make this edit ;)

netbeans debug showing child blocks

EDIT: Added to answer OP's question about core text list

A core text list is a magento class, which holds a list of child blocks, and will generate a concatenated HTML output of all the child blocks as one HTML block.

a good example of one is 'before_body_end' as define in the layout page.xml file

<block type="core/text_list" name="before_body_end" as="before_body_end" translate="label">
                <label>Page Bottom</label>
            </block>

thus, when you assign a child block to a core/text_list derived block, the child's HTML will be generated for you.

you will find the 'magic' in Mage_Core_Block_Text_List::_toHtml()

Related Topic