2

I want to extend the customer account dashboard menu with a new section shown in the picture below. What is the best practice to do this?

enter image description here

3

you can simple add these link by adding your phtml file

<customer_account>
        <reference name="left">
            <block type="core/template" name="test_dashboard-left" after="-" template="test/test-left.phtml"
                />
        </reference>
    </customer_account>

your phtml file

<div class="block block-account">
    <div class="block-title">
        <strong><span>My Custom Section</span></strong>
    </div>

    <div class="block-content">
        <ul>
<li>My Ownl lInk</li>
<li>My Ownl lInk1</li>
</ul>
</div>
</div>
  • Hi Qaisar in which file must I add the customer_account section and what else do I need to configure? i.e. a new module or only a template? – ClassMP Nov 3 '15 at 5:59
  • in local.xml of your theme or customer.xml it upto you – Qaisar Satti Nov 3 '15 at 6:00
  • i update my answer kindly check it.. – Qaisar Satti Nov 3 '15 at 6:30
  • Qaisar can you please show the path where to place the new files? – ClassMP Nov 3 '15 at 7:27
  • maindirecotry/app/design/frontend/base/default/template/test/test-left.phtml – Qaisar Satti Nov 3 '15 at 7:30
2

Follow this

Make sure You should edit theme file not a core file

Step 1: Activating The Module

\app\etc\modules\Istockphp_Customerpage.xml

<?xml version="1.0" encoding="utf-8"?>
<!--step 1: registering the module-->
<config>
    <modules>
        <Istockphp_Customerpage>
            <active>true</active>
            <codePool>local</codePool>
        </Istockphp_Customerpage>
    </modules>
</config>

Step 2: Config File

\app\code\local\Istockphp\Customerpage\etc\config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Istockphp_Customerpage>
          <version>0.1.0</version>
        </Istockphp_Customerpage>
    </modules>

    <global>
        <blocks> <!--Block folder-->
            <istockphp>
                <class>Istockphp_Customerpage_Block</class>
            </istockphp>
        </blocks>
    </global>

    <frontend>
        <routers>
            <istockphp>
                <use>standard</use>
                <args>
                    <module>Istockphp_Customerpage</module>
                    <frontName>custompage</frontName>
                </args>
            </istockphp>

            <customer>
                <args>
                    <modules>
                        <!--name / before: change existing -->
                        <istockphp before="Mage_Customer">Istockphp_Customerpage</istockphp>
                    </modules>
                </args>
            </customer>
        </routers>

        <layout>
          <updates>
            <istockphp>
                          <!--app\design\frontend\default\default\layout\customer\custompage.xml-->
              <file>customer/custompage.xml</file>
            </istockphp>
          </updates>
        </layout>

    </frontend>
 </config>

Step 3: Controller File

\app\code\local\Istockphp\Customerpage\controllers\AccountpageController.php

<?php class Istockphp_Customerpage_AccountpageController extends Mage_Core_Controller_Front_Action {     protected function _getSession() {         return Mage::getSingleton('customer/session');     }     public function preDispatch() {         parent::preDispatch();             if (!Mage::getSingleton('customer/session')->authenticate($this)) {
                $this->setFlag('', 'no-dispatch', true);
        }
    }

    // http://localhost/istockphp_magento/custompage/accountpage/index
    public function indexAction() { // landing page
        $this->loadLayout();
        $this->renderLayout();

    }

}

Step 4: Block

\app\code\local\Istockphp\Customerpage\Block\Customer.php

<?php

class Istockphp_Customerpage_Block_Customer extends Mage_Customer_Block_Account_Dashboard  {

}

Step 5: Adding link in Customer Dashboard

\app\design\frontend\default\default\layout\local.xml

<layout version="0.1.0">
    <!--add link to the customer panel-->
    <customer_account>
        <reference name="customer_account_navigation">
            <action method="addLink" translate="label" module="customer">
                <name>custom page</name>
                <!--Customer Block/AccountpageController.php-->
                <path>customer/accountpage/</path>
                <label>Custom Page</label>
            </action>
        </reference>
    </customer_account>

</layout>

Step 6: Update Layout

\app\design\frontend\default\default\layout\customer\custompage.xml

<layout version="0.1.0">
     <!--Istockphp\Customerpage\controllers\AccountpageController.php-->
    <customer_accountpage_index translate="label">
        <label>Custom Page</label>
            <reference name="head">
                    <action method="setTitle"><title>Custom Page</title></action> <!--Page Title-->
            </reference>
        <!-- Mage_Customer -->
        <update handle="customer_account"/>
        <reference name="my.account.wrapper">
            <!--name in config file / Istockphp\Customerpage\Block\Customer.php-->
            <block type="istockphp/customer" name="istockphp" before="-" template="customer/custom_customer_page.phtml"/>
        </reference>
    </customer_accountpage_index>
</layout>

Step 7: Template File

\app\design\frontend\default\default\template\customer\custom_customer_page.phtml

<div class="page-title">


<h1><?php echo $this->__('Customer Custom Page') ?></h1>


</div>


<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>

 Welcome to my custom page


<div class="buttons-set">


<a href="<?php echo $this->getUrl('customer/account/') ?>"><small>&laquo; </small><?php echo $this->__('Back') ?></a>

</div>


<script type="text/javascript">
</script>
  • I found this tutorial too. But I want to add a complete new tab/section 'My custom section' with new links (see the pic) – ClassMP Nov 2 '15 at 19:52
  • Use same just add H1 tag before and then create another phtml and then call your .xml file – Magento 2 Nov 3 '15 at 4:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.