0

I've trying for many hours to create a custom admin module but no luck so far. Here's my code:

/app/code/local/CompanyName/MailView/etc/config.xml:

<?xml version="1.0"?>
<config>
 <modules>
   <CompanyName_MailView>
    <version>0.1.0</version>
</CompanyName_MailView>
</modules>
<admin>
<routers>
    <adminhtml>       
       <!-- <use>admin</use>          -->
        <args>
            <modules>
                <mailview before="Mage_Adminhtml">CompanyName_MailView</mailview>
            </modules>
        </args>
    </adminhtml>
</routers>
</admin>
<global>
<helpers>
    <companyname_mailview>
        <class>CompanyName_MailView_Helper</class>
    </companyname_mailview>
</helpers>
</global>
</config> 

/app/code/local/CompanyName/MailView/etc/adminhtml.xml

  <?xml version="1.0"?>
 <config>
<menu>
    <companyname translate="title" module="CompanyName_mailview">
        <title>View Emails</title>
        <sort_order>999</sort_order>
        <action>adminhtml/mailview/index</action>         
    </companyname>
</menu>
  <acl>
    <resources>
        <admin>
            <children>                
                <CompanyName translate="title" module="companyname_mailview">
                    <title>Top Level Pulse Storm Menu Item</title>
                    <sort_order>1</sort_order>
                     <children>
                        <example>
                            <title>Example Menu Item</title>
                        </example>
                    </children>
                </CompanyName>
            </children>
        </admin>
    </resources>
</acl>
  </config> 

and here's my controller: app/code/local/CompanyName/MailView/controllers/MailViewController.php:

<?php
class CompanyName_MailView_MailViewController extends 
 Mage_Adminhtml_Controller_Action
{
    public function indexAction()
  {
      $this->loadLayout();
      $this->renderLayout();
  }
}

and my helper: app/code/local/CompanyName/MailView/Helper/Data.php

<?php
 class CompanyName_MailView_Helper_Data extends 
 Mage_Core_Helper_Abstract
{
 }    

The module appears in the admin panel. When I click on it though I get an error 404 page not found.

I've been following this tutorial but no luck so far. What am I missing here? Thank you

  • Have you tried logging out and back in again on the admin after installing the module? – seanbreeden Sep 27 '17 at 14:43
  • Yes.. in the following sequence: clear cache, log out, log in and clear cache again – Stefanos Sep 27 '17 at 14:56
  • It looks like you are missing <adminhtml><layout><updates> in your config.xml, but calling the loadLayout and renderLayout in your controller. – seanbreeden Sep 27 '17 at 15:21
  • what do I add exactly ? – Stefanos Sep 27 '17 at 15:31
1

You have a few minor problems. Compare the files below with your xml to see the fixes.

config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <CompanyName_MailView>
            <version>0.1.0</version>
        </CompanyName_MailView>
    </modules>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <CompanyName_MailView before="Mage_Adminhtml">CompanyName_MailView_Adminhtml</CompanyName_MailView>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
    <global>
        <helpers>
            <companyname>
                <class>CompanyName_MailView_Helper</class>
            </companyname>
        </helpers>
    </global>
</config>

adminhtml.xml

<?xml version="1.0"?>
<config>
    <menu>
        <companyname translate="title">
            <title>View Emails</title>
            <sort_order>999</sort_order>
            <action>adminhtml/mailview</action>
        </companyname>
    </menu>
    <acl>
        <resources>
            <admin>
                <children>
                    <companyname translate="title">
                        <title>View Emails</title>
                        <sort_order>100</sort_order>
                    </companyname>
                </children>
            </admin>
        </resources>
    </acl>
</config>

Change the case on your mailview controller from MailViewController.php to MailviewController.php. Move it to a subfolder of Adminhtml so the full path will be: app/code/local/CompanyName/MailView/controllers/Adminhtml/MailviewController.php

<?php

class CompanyName_MailView_Adminhtml_MailviewController 
extends Mage_Adminhtml_Controller_Action
{

    public function indexAction() {

        die('This admin controller works!');

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

    }

}

Make the above changes, flush cache, log out of admin then log back in and you will be able to click your View Mails link. The test in MailviewController.php will dump "This admin controller works!". After you get this part working, look into adding layout overrides in your config.xml to continue building out your admin module.

0

Your Helper class seems top be wrong. Please fix it first.

<?php
class Converge_MailView_Helper_Data extends Mage_Core_Helper_Abstract
{

}   

Also in config.xml. There is a Typo.

<helpers>
    <companyname_mailview>
        <class>CompanyName_MailView_Helper</class>
    </companyname_mailview>
</helpers>

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.