1

I have been working on this and this tutorial to add my custom link in customer account dashboard and then clicked on that link, open my custom page.

I have changed the Namespace and Module name. So far I am successful in adding a new link in dashboard, but when click on that link, it shows me blank page (no 404 error). I see below image and no block loading my .phtml file when the URL is http://localhost/magento_18/index.php/customer/modulename/

enter image description here

Below is my code for the module.

config.xml

 <?xml version="1.0"?>
    <config>
        <modules>
            <Namespace_Modulename>
                <version>1.0.0</version>
            </Namespace_Modulename>
        </modules>
        <global>
            <helpers>
                <modulename>
                    <class>Namespace_Modulename_Helper</class>
                </modulename>
            </helpers>
            <resources>
                <modulename_setup>
                    <setup>
                        <module>Namespace_Modulename</module>
                        <class>Mage_Eav_Model_Entity_Setup</class>
                    </setup>
                    <connection>
                        <use>core_setup</use>
                    </connection>
                </modulename_setup>
                <modulename_write>
                    <connection>
                        <use>core_write</use>
                    </connection>
                </modulename_write>
                <modulename_read>
                    <connection>
                        <use>core_read</use>
                    </connection>
                </modulename_read>
            </resources>
            <blocks>
                <namespace_modulename>
                    <class>Namespace_Modulename_Block</class>
                </namespace_modulename>
            </blocks>
        </global>
        <frontend>
            <routers>
                <namespace_modulename>
                    <use>standard</use>
                    <args>
                        <module>Namespace_Modulename</module>
                        <frontName>modulename</frontName>
                    </args>
                </namespace_modulename>
                <customer>
                    <args>
                        <modules>
                        <namespace before="Mage_Customer">Namespace_Modulename</namespace>
                        </modules>
                    </args>
                </customer>
            </routers>
            <layout>
                <updates>
                    <namespace_modulename module="Namespace_Modulename">
                        <file>modulename.xml</file>
                    </namespace_modulename>
                </updates>
            </layout>
        </frontend>
        <adminhtml>
            <layout>
                <updates>
                    <namespace_modulename module="Namespace_Modulename">
                        <file>modulename.xml</file>
                    </namespace_modulename>
                </updates>
            </layout>
        </adminhtml>
    </config>

My layout at app/design/frontend/base/default/layout/modulename.xml

<?xml version="1.0"?>
<layout>
    <customer_account>
        <reference name="customer_account_navigation">
            <action method="addLink" translate="label" module="modulename">
                <name>Test Module</name>
                <path>customer/modulename/</path>
                <label>My Test Module</label>
            </action>
        </reference>
    </customer_account>
    <modulename_modulename_index translate="label">
        <label>My Test Module</label>
        <reference name="head">
            <action method="setTitle"><title>My Test Module</title></action>
        </reference>
        <update handle="customer_account"/>
        <reference name="my.account.wrapper">
            <block type="core/template" name="modulename" template="modulename/customer/modulename.phtml"/>
        </reference>
    </modulename_modulename_index>
</layout>

My controller at app\code\community\Namespace\Modulename\controllers\ModulenameController.php

<?php

class Namespace_Modulename_ModulenameController extends Mage_Core_Controller_Front_Action {

    protected function _getSession() {
        return Mage::getSingleton('customer/session');
    }

    public function preDispatch() {

        parent::preDispatch();
        $action = $this->getRequest()->getActionName();
        $loginUrl = Mage::helper('customer')->getLoginUrl();
        if (!Mage::getSingleton('customer/session')->authenticate($this, $loginUrl)) {
            $this->setFlag('', self::FLAG_NO_DISPATCH, true);
        }
    }

    public function indexAction() {

        $this->loadLayout();
        $this->renderLayout();
    }

}

Someone pls help and guide.

Thanks.

2

Try to change path to "modulename" instead of "customer/modulename" in your layout customer.xml. Your router's frontname is "modulename" and not "customer/modulename".

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.