1

I am adding a menu item to Admin.

Could someone tell me why I get a 404?

app/etc/modules/Privacybuilder_Pbtab.xml

<config>
<modules>
    <Privacybuilder_Pbtab>
        <active>true</active>
        <codePool>local</codePool>
    </Privacybuilder_Pbtab>
</modules>
</config>

app/code/local/Privacybuilder/Pbtab/etc/config.xml

<config>
<modules>
 <Privacybuilder_Pbtab>
   <version>0.1.0</version>
 </Privacybuilder_Pbtab>
</modules>
<global>
    <models />
    <blocks />
    <resources />
    <extraconfig />
    <helpers>
      <pbtab>
  <class>Privacybuilder_Pbtab_Helper</class>
      </pbtab>
    </helpers>
</global>
<admin>
    <routers>
     <adminhtml>
            <args>
                <modules><pbtab>Privacybuilder_Pbtab</pbtab></modules>
    </args>
 </adminhtml>
    </routers>
</admin>
</config>

app/code/local/Privacybuilder/Pbtab/etc/adminhtml.xml

<config>
<menu>

<pbtab>
        <title>Privacy Builder</title>
        <sort_order>9999</sort_order>
        <action>adminhtml/pbtab</action>
 </pbtab>
</menu>
</config>

The new menu item links to

http://magento.local:8080/magento/index.php/admin/pbtab/index/key/2b00863c2b8246bc9d553c89ce39d523/

app/code/local/Privacybuilder/Pbtab/controllers/IndexController.php - OK

app/code/local/Privacybuilder/Pbtab/Helper/Data.php - OK

app/design/adminhtml/default/default/layout/privacybuilder.xml

<layout>
<adminhtml_pbtab_index>
 <reference name="content">
   <block type="adminhtml/template" name="pbadminform" template="privacybuilder/adminform.phtml"/>
 </reference>

app/design/adminhtml/default/default/template/adminform.phtml - OK

I believe that the controller is now loading correctly. The 404 is happening at some point after this.

Thanks

Robert

7
  • 2
    I started to write a reply, but there is so much wrong in what you have posted I would just be writing the module for you... Read up about Magento modules with namespaces and module names and then look again at what you have done. Nov 26 '14 at 17:32
  • Thanks Jonathan. I can see only 3 differences as compared with the document cited by mbalparda below: (i) I'm not using a namespace, and (ii) I'm using the extended routers format in config.xml (iii) I don't have a modules declaration in my local config.xml. Would any of these lead to the 404 do you think? Is the use of a namespace compulsory do you think? Nov 27 '14 at 10:26
  • I didn't reference any article, but yes namespace is absolutely required. Nov 27 '14 at 10:31
  • OK. Great Jonathan. Would you like to give this as an answer and I will upvote it? Nov 27 '14 at 15:15
  • Great if you have got things sorted, just upvote my comment if that was the issue, don't think the one liner comment really warrants an answer! Nov 27 '14 at 15:40
1

Solved. Should be

app/code/local/Privacybuilder/Pbtab/controllers/PbTabController.php

with the class

Privacybuilder_Pbtab_PbtabController extends Mage_Adminhtml_Controller_Action

BTW there seems to be a disagreement as to whether

<admin>
<routers>
 <adminhtml>
        <args>
            <modules><pbtab>Privacybuilder_Pbtab</pbtab></modules>
</args>
</adminhtml>
</routers>
</admin>

is correct. Acceptable variants appear to be

<admin>
    <routers>
     <adminhtml>
            <args>
                <modules><Privacybuilder_Pbtab after="Mage_Adminhtml">Privacybuilder_Pbtab</Privacybuilder_Pbtab></modules>
    </args>
 </adminhtml>
    </routers>
 </admin>

and also

<admin>
    <routers>
     <adminhtml>
            <use>admin</use>
             <args>
                <module>Privacybuilder_Pbtab</module>
                <frontname>pbtab</frontname>
               </args>
 </adminhtml>
    </routers>
</admin>
1
  • The first example above is not correct, the second and third are both correct. The second tells Magento to look at your module for a match if one is not found in Mage_Adminhtml which means you use the existing admin frontName (you can also use before="Mage_Adminhtml" and this is more common), the third sets up your own frontName instead of using the admin frontName (note frontname is wrong, capital N). If you look at Mage_Adminhtml config.xml you will see configuration as per the third example. Nov 28 '14 at 10:30
0

This has a lot of errors. I suggest you to download this and see how it is created. Once you fully understand how does an Admin module works you will be able to solve your own issues. The link im giving you has a basic Magento module with most of the features you would expect.

3
  • Thanks mpalparda. I'm sure I don't speak only for myself when I say that following a Magento recipe, let alone understanding the Admin module fully, is very difficult! Nov 27 '14 at 10:31
  • I dont quite understand your comment. Seeing code is one way, not to say the best, to learn.
    – mbalparda
    Nov 27 '14 at 11:49
  • I think Robert was saying that although the link is helpful, Magento itself is a maze of paths and has a rather steep learning curve. Also, that link is broken. Do you have an updated link? May 20 '15 at 21:55

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.