0

I Created a custom module. My requirement is to add new link after all links in Customer My Account. When click on that new link a new page should be shown.

My Code is

Step 1. Created new file in app/etc/modules named Badge_page.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Badge_page>
      <active>true</active>
      <codePool>local</codePool>
      <depends>
        <Mage_Page />
      </depends>
    </Badge_page>
  </modules>
</config>

Step 2. Created new file in app/code/local/Badge/Page/etc named config.xml

<?xml version="1.0"?>
<config>
    <global>
        <modules>
                <Badge_Page>
                        <version>0.1.0</version>
                </Badge_Page>
        </modules>
    <blocks>
            <achievements>
         <achievements>Badge_Page_Block_Achievements</achievements>
            </achievements>
     </blocks>
        </global>
       <frontend>
                <routers>
                        <achievements>
                                <use>standard</use>
                                <args>
                                      <frontName>achievements</frontName>
                                      <module>Badge_Page</module>
                                </args>
                        </achievements>
                </routers>
        <layout>
            <updates>
                <achievements>
                      <file>achievements.xml</file>
                </achievements>
            </updates>
            </layout>
        </frontend>
</config>

Step 3. Created Controller File app/code/local/Badge/Page/controllers named IndexController.php

<?php 
class Badge_Page_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
     $this->loadLayout();
     $this->getLayout()->getBlock('head')->setTitle($this->__('My Badges'));
    $this->renderLayout();
    }
}

Step 4. Created Block File app/code/local/Badge/Page/Block named Achievements.php

<?php 

class Badge_Page_Block_Achievements extends Mage_Core_Block_Template
{
  public  function _construct()
    {
        parent::_construct(); // TODO: Change the autogenerated stub
        $this->setTemplate("page/badgepage.phtml");
    }
}

Step 5. And then Updated my local.xml file in app/design/frontend/Package/template/layout

 <?xml version="1.0"?>
    <layout version="0.1.0">
       <customer_account>
   <reference name='customer_account_navigation'>
        <action method="addLink" translate="label" module="customer">
        <name>badgepage</name> 
        <path>achievements</path> 
        <label>My Badges</label></action> 
   </reference>

</customer_account>

    </layout>

Step 6 Created achievements.xml file under app/design/frontend/Package/template/layout

<?xml version="1.0"?>
<layout version="0.1.0">
    <achievements_index_index translate="label">
        <label>Badge Page</label>
        <update handle="customer_account"/>
        <reference name="root">
            <action method="setTemplate"><template>page/badgepage.phtml</template></action>
        </reference>
        <reference name="content">
            <block type="achievements/index" name="page_content_heading" template="page/badgepage.phtml"/>
        </reference>
</achievements_index_index>

</layout>

Step 7 Created badgepage.phtml under app/design/frontend/Package/template/badge/

<?php echo "My Custom Module Output;"?>

Here I can see the link in My Account Dashboard But when I Click on it I was getting 404 Error.. Where am I going. Please Suggest me the Solution.

Thanks.

  • Can you Please Mark any answer as accepted from below which you found helpful or post your solution and mark it as accepted in order to close the question. – Piyush Feb 27 '18 at 7:06
0

app/etc/modules Badge_Page.xml and not Badge_page.xml

<?xml version="1.0"?>
<config>
  <modules>
    <Badge_Page>
      <active>true</active>
      <codePool>local</codePool>
      <depends>
        <Mage_Page />
      </depends>
    </Badge_Page>
  </modules>
</config>
  • Thanks for the response, But I didn't see any changes in both codes anyways I replaced the code. But again same issue 404 ERROR . I thought I did mistake Step 5 Path <path>badgepage</path> . Can you correct me if I am wrong. – Raghav Nov 1 '17 at 4:52
0

Along with @Prince Answer, Also change your controller's action to

public function indexAction()
{
 $this->loadLayout();
 $this->renderLayout();
}
  • Thanks for the response. It didn't worked for me. I thought I did mistake Step 5 Path <path>badgepage</path> . Can you correct me if I am wrong. – Raghav Nov 1 '17 at 4:49
  • 1
    @Raghav in path node value try achievements instead of badgepage – Piyush Nov 1 '17 at 5:10

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.