0

I am following Alan Storms documentation to add a custom tab to accounts page but unfortunately I am running into a hiccup. I am not able to route and load my controller when I click on my custom link tab within accounts. I can definitely add the custom tab but routing the url once I click on it is not doing anything. Running version 1.9.0.1

app/code/community/Brandster/CustomAccount/etc/config.xml

<?xml version="1.0"?>
<config>
  <frontend>
    <layout>
      <updates>
        <brandster_customaccount module="Brandster_CustomAccount">
            <file>brandster_customaccount.xml</file>
        </brandster_customaccount>
      </updates>
    </layout>
    <routers>
      <brandster_customaccount>
        <use>standard</use>
        <args>
          <module>Brandster_CustomAccount</module>
          <frontName>brandster_customaccount</frontName>
        </args>
      </brandster_customaccount>
    </routers>
  </frontend>
  <global>
    <helpers>
      <brandster_customaccount>
        <class>Brandster_CustomAccount_Helper</class>
      </brandster_customaccount>
    </helpers>
  </global>
</config>

app/design/frontend/mytheme/mypackage/layout/brandster_customaccount.xml

<?xml version="1.0"?>
<layout>
  <customer_account>
    <reference name="customer_account_navigation">
      <action method="addLink">
        <name>our_new_section</name>
        <path>brandster_customaccount/index/index</path>
        <label>Terms &amp; Conditions</label>
      </action>
    </reference>
  </customer_account>
  <brandster_customaccount_index_index>
    <update handle="customer_account" />
  </brandster_customaccount_index_index>
</layout>

app/code/community/Brandster/CustomAccount/Controllers/IndexController.php

<?php
class Brandster_CustomAccount_IndexController extends Mage_Core_Controller_Front_Action {
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);
    }
  }
}

app/code/community/Brandster/CustomAccount/Helper/Data.php

<?php
class Brandster_CustomAccount_Helper_Data extends Mage_Core_Helper_Abstract
{

}

1 Answer 1

0

Your code is actually fine, you simply miss an indexAction() method in your controller. Just add

public function indexAction()
{
    $this->loadLayout();
    $this->renderLayout();
}

to app/code/community/Brandster/CustomAccount/controllers/IndexController.php. Please note that the folder should be named controllers and not Controllers, otherwise Magento won't find your class.

3
  • WOW.. thanks for catching those two errors, I have corrected it as you stated but still no success rendering I get the 404 page with an error in the url errors/report.php?id=1011755426413&skin=default
    – Lugana
    Jul 13, 2016 at 20:11
  • You can find the details of the error under var/report/1011755426413
    – fmrng
    Jul 14, 2016 at 6:28
  • Man I cant thank you enough! Magento being so huge is intimidating tending to overlook some simple mistakes. I resolved the issue for the error turns out I had unnecessary white space and I made sure I closed my PHP tag.
    – Lugana
    Jul 14, 2016 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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