0

I've used a yeoman generator to build a Magento Module skeleton.

I can access the frontend module simply with: http://prueba.com/index.php/prueba/index

But I can't make it work the admin. These are my files:

/etc/adminhtml.xml

<config>

        <menu>
            <prueba>
                <title>My Tab</title>
                <sort_order>1</sort_order>
                     <action>adminhtml/prueba/index</action>
            </prueba>        
        </menu>
    </config>

/controllers/adminhtml/IndexController.php

<?php
/**
 * Index Adminhtml Controller
 *
 */
class Altimea_Prueba_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action 
{
    /**
     * Index Action
     */
    public function indexAction()
    {
        $this->loadLayout();
        $this->renderLayout();
        echo 'hello';
    }
}

/etc/config.xml

<?xml version="1.0"?>
<config>
    <modules>
        <Altimea_Prueba>
            <version>0.1.0</version>
        </Altimea_Prueba>
    </modules>
    <global>
        <models>
            <altimeaprueba>
                <class>Altimea_Prueba_Model</class>
            </altimeaprueba>
        </models>
        <blocks>
            <altimeaprueba>
                <class>Altimea_Prueba_Block</class>
            </altimeaprueba>
        </blocks>
        <helpers>
            <altimeaprueba>
                <class>Altimea_Prueba_Helper</class>
            </altimeaprueba>
        </helpers>

        <resources>
            <altimeaprueba_setup>
                <setup>
                    <module>Altimea_Prueba</module>
                    <class>Altimea_Prueba_Model_Resource_Setup</class>
                </setup>
            </altimeaprueba_setup>
        </resources>

    </global>

    <frontend>

        <layout>
            <updates>
                <altimeaprueba>
                    <file>altimeaprueba.xml</file>
                </altimeaprueba>
            </updates>
        </layout>


        <routers>
            <altimeaprueba>
                <use>standard</use>
                <args>
                    <module>Altimea_Prueba</module>
                    <frontName>prueba</frontName>
                </args>
            </altimeaprueba>
        </routers>

    </frontend>


    <adminhtml>

        <layout>
            <updates>
                <altimeaprueba>
                    <file>altimeaprueba.xml</file>
                </altimeaprueba>
            </updates>
        </layout>

    </adminhtml>

    <admin>
        <routers>
            <altimeaprueba>
                <use>admin</use>
                <args>
                    <module>Altimea_Prueba</module>
                    <frontName>prueba</frontName>
                </args>
            </altimeaprueba>
        </routers>
    </admin>


</config>

4 Answers 4

1

When create a magento admin module you can create it in one of two ways. Since you have both a front and backend controller try changing your admin route to <frontname>admin_prueba</frontname> then try http://prueba.com/index.php/admin_prueba/index

<adminhtml>
    <menu>
        <menu1 translate="title" module="customlist">
            <title>ActiveCodeline SampleModule1</title>
            <sort_order>60</sort_order>
            <children>
                <menuitem1 module="SampleModule1">
                    <title>Menu item 1</title>
                    <action>{{customlist}}/index</action>
                </menuitem1>


<admin>
    <routers>
        <samplemodule1>
            <use>admin</use>
            <args>
                <module>ActiveCodeline_SampleModule1</module>
                <frontname>admin_customlist</frontname>
            </args>
        </samplemodule1>
    </routers>
</admin>

or

<adminhtml>
    <menu>
        <menu1 translate="title" module="customlist">
            <title>ActiveCodeline SampleModule1</title>
            <sort_order>60</sort_order>
            <children>
                <menuitem1 module="SampleModule1">
                    <title>Menu item 1</title>
                    <action>{{adminhtml/customlist}}/index</action>
                </menuitem1>

<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <Company_CustomList before="Mage_Adminhtml">Foo_Bar_Adminhtml</Company_CustomList>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>
0

You have missed to add this in config.xml

    <admin>
    <routers>
        <adminhtml>
            <use>admin</use>
            <args>
            <modules>
                <altimea_prueba after="Mage_Adminhtml">Altimea_Prueba_Adminhtml</altimea_prueba>
            </modules>
            </args>
        </adminhtml>
    </routers>
</admin>
2
  • Still doesn't load the controller having that in config.xml
    – codiaf
    Jan 12, 2015 at 16:42
  • added <use>admin</use> in answer. Jan 12, 2015 at 16:50
0

In config.xml, change this:

<admin>
    <routers>
        <altimeaprueba>
            <use>admin</use>
            <args>
                <module>Altimea_Prueba</module>
                <frontName>prueba</frontName>
            </args>
        </altimeaprueba>
    </routers>
</admin>

To this:

<admin>
    <routers>
        <altimea_prueba>
            <use>admin</use>
            <args>
                <module>Altimea_Prueba</module>
                <frontName>prueba</frontName>
            </args>
        </altimea_prueba>
    </routers>
</admin>

If you want to see your "hello" printed out, in IndexController.php, add exit(); after your echo "hello";

0

Just a reference It took me ages to figure out that

<args> <modules> <myrandomtag before="Mage_Adminhtml"> My_Module_Adminhtml </myrandomtag> </modules> </args>

IS NOT SAME AS

<args> <modules> <myrandomtag before="Mage_Adminhtml">My_Module_Adminhtml</myrandomtag> </modules> </args>

So there should be no space or new line inside your random tag

Your Answer

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

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