0

I'm following this tuto http://www.magentogarden.com/blog/how-does-magento-adminhtml-grid-work.html to create an admin module.

After trying lots of solutions, i still can't reach my admin controller. I get a 404.

/var/www/app/code/local/Namespace/Configslider/etc/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
        <modules>
                <Namespace_Configslider>
                        <version>0.1.0</version>
                </Namespace_Configslider>
        </modules>

        <global>
                <helpers>
                        <configslider>
                                <class>Namespace_Configslider_Helper</class>
                        </configslider>
                </helpers>

                <blocks>
                        <configslider>
                                <class>Namespace_Configslider_Adminhtml_Block</class>
                        </configslider>
                </blocks>
        </global>

        <admin>
                <routers>
                        <configslider>                               
                                <args>
                                        <modules>
                                                <Namespace_Configslider after="Mage_Adminhtml">Namespace_Configslider_Adminhtml</Namespace_Configslider>
                                        </modules>                                
                                </args>
                        </configslider>
                </routers>
        </admin>
</config>

/var/www/app/code/local/Namespace/Configslider/etc/adminhtml.xml

<?xml version="1.0"?>
<config>
<menu>
        <cms>
                <children>
                        <namesptest module="configslider">
                                <title>Configure the slider</title>
                                <sort_order>50</sort_order>
                                <action>adminhtml/configslider/index</action>
                        </namesptest>
                </children>
        </cms>
</menu>

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

<acl>
        <resources>
                <admin>
                        <children>                              
                                <cms>
                                        <children>
                                                <namesptest translate="title" module="configslider">
                                                        <title>NameSpace - Slider</title>
                                                        <sort_order>100</sort_order>
                                                </namesptest>
                                        </children>
                                </cms>
                        </children>
                </admin>
        </resources>
</acl>
</config>

The admin generated menu link URI is : index.php/admin/configslider/index/

EDIT : From the alan storm tuto, magento generate the following controller file name : /var/www/app/code/core/Mage/Index/controllers/Adminhtml/ConfigsliderController.php and magento can't find the controller class name.

EDIT 2 : /var/www/app/design/adminhtml/default/default/layout/configslider.xml

<?xml version="1.0"?>
<layout>

        <configslider_adminhtml_index_index>
                <reference name="content">
                        <block type="configslider/adminhtml_configslider" name="configslider"></block>
                </reference>
        </configslider_adminhtml_index_index>
</layout>

EDIT 3 : NameSpace/Configslider/Block/Adminhtml/Configslider/Init.php

<?php
class NameSpace_Configslider_Block_Adminhtml_Configslider_Init extends Mage_Adminhtml_Block_Widget_Grid_Container
{
    public function __construct()
    {
        $this->_blockGroup = 'configslider';
        $this->_controller = 'adminhtml_configslider';
        $this->_headerText = Mage::helper('configslider')->__('Configure slider');      
        parent::__construct();
    }
}

NameSpace/Configslider/Block/Adminhtml/Configslider/Grid.php

<?php
class NameSpace_Configslider_Block_Adminhtml_Configslider_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
    public function __construct()
    {
        parent::__construct();
        $this->setId('configslider_id');
        $this->setDefaultSort('id');
        $this->setDefaultDir('asc');
    }
...

EDIT 4 : Below my module tree :

Configslider/
  Block/
    Adminhtml/
      Configslider/
        Grid.php
        Init.php
  controllers/
    Adminhtml/
      IndexController.php
  Model/
    Config.php
    Resource/
      Config.php
      Setup.php
      Config/
        Collection.php
  Helper/
    Data.php
  sql/
    configslider_setup/
      mysql4-install-0.1.0.php

Do you know where i'm wrong ?

  • There are some things in the wrong order and parts missing in the xml configs, if you can post the structure of your extension then I can update my answer with all of the correct xml files and missing files you need. – jesseconnr Feb 14 '14 at 19:02
2

This should be adminhtml below routers and not configsliders in your config.xml.

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

Also, I'd recommend this guide.

http://alanstorm.com/magento_admin_hello_world_revisited

Updated answer based on new info.

Without re-creating the entire module, this is what I changed to get the admin page to show up and not 404. I substituted the namespace for my testing so you will need to change that. You should be able to take it from here.

Pay close attention to the order of the namespace_extensionname in the config edits, these are important.

Modified: app/etc/local/Stackexchange/Configslider/etc/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <Stackexchange_Configslider>
            <version>0.1.0</version>
        </Stackexchange_Configslider>
    </modules>

    <global>
        <helpers>
            <stackexchange_configslider>
                <class>Stackexchange_Configslider_Helper</class>
            </stackexchange_configslider>
        </helpers>

        <blocks>
            <configslider>
                <class>Namespace_Configslider_Adminhtml_Block</class>
            </configslider>
        </blocks>
    </global>

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

    <adminhtml>
        <layout>
            <updates>
                <stackexchange_configslider module="stackexchange_configslider">
                    <file>stackexchange_configslider.xml</file>
                </stackexchange_configslider>
            </updates>
        </layout>
    </adminhtml>
</config>

Modified: app/etc/local/Stackexchange/Configslider/etc/adminhtml.xml

<?xml version="1.0"?>
<config>
    <menu>
        <cms>
            <children>
                <stackexchange translate="title" module="stackexchange_configslider">
                    <title>Configure the slider</title>
                    <sort_order>50</sort_order>
                    <action>adminhtml/configslider/index</action>
                </stackexchange>
            </children>
        </cms>
    </menu>

    <acl>
        <resources>
            <admin>
                <children>
                    <cms>
                        <children>
                            <stackexchange translate="title" module="stackexchange_configslider">
                                <title>Configure the slider</title>
                                <sort_order>100</sort_order>
                            </stackexchange>
                        </children>
                    </cms>
                </children>
            </admin>
        </resources>
    </acl>
</config>

Missing: app/etc/local/Stackexchange/Configslider/controllers/Adminhtml/ConfigsliderController.php

<?php

class Stackexchange_Configslider_Adminhtml_ConfigsliderController extends Mage_Adminhtml_Controller_Action
{
    public function indexAction()
    {
        $this->loadLayout();
        $this->renderLayout();
    }
}
  • I also follow this alan storm tuto, and try your solutions but the result remains the same :/ – canardman Feb 14 '14 at 18:35
  • I added to the post some debug info – canardman Feb 14 '14 at 18:45
  • Can you post your directory layout of your module? You seem to be missing some necessary files. – jesseconnr Feb 14 '14 at 18:46

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.