3

Problem Statement: I have created an adminmenu and call an action on it. For the action, I have created one controller. When click on menu it redirects to 404 page on front side.(Can't access to controller and it jump to frontarea) Code is as below:

config.xml (demo/etc/config.xml)

<?xml version="1.0"?>
<config>
    <modules>
        <Sevenbits_Demo>
            <version>1.0.0</version>
        </Sevenbits_Demo>
    </modules>
    <global>
        <models>
            <demo>
                <class>Sevenbits_Demo_Model</class>
            </demo>
        </models>
        <helpers>
            <demo>
                <class>Sevenbits_Demo_Helper</class>
            </demo>
        </helpers>
        <blocks>
            <demo>
                <class>Sevenbits_Demo_Block</class>
            </demo>
        </blocks>
    </global>
    <!-- Frontend Controller started here -->
    <frontend>
        <routers>
            <demo>
                <use>standard</use>
                <args>
                    <frontName>Demo</frontName>
                    <module>Sevenbits_Demo</module>
                </args>
            </demo>
        </routers>
        <layout>
            <updates>
                <demo>
                    <file>demo.xml</file>
                </demo>

            </updates>
        </layout>
    </frontend>
    <!-- Frontend Controller end here -->

    <!-- Frontend Controller started here -->
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <module>
                        <demo before="Mage_Adminhtml">
                            Sevenbits_Demo_Adminhtml
                        </demo>

                    </module>
                </args>
            </adminhtml>
        </routers>
    </admin>
    <!-- Frontend Controller end here -->
</config>

adminhtml.xml(demo/etc/adminhtml.xml)

<?xml version="1.0"?>
<config>
    <menu>
        <demo transalte="title" module="demo">
            <title>Mage Hunter</title>
            <sort_order>1000</sort_order>
            <action>Adminhtml/demo</action>
        </demo>
    </menu>
</config>

DemoController.php (/demo/controllers/Adminhtml/DemoController.php)

<?php

class Sevenbits_Demo_Adminhtml_DemoController extends Mage_Adminhtml_Controller_Action
{

    public function indexAction()
    {
        //$this->loadLayout();
        echo "Hwll";
        return $this->renderLayout();

    }
}

After Menu click (page redirect to 404 page and display frontend layout) get this output.

1

remove the new lines in here:

<demo before="Mage_Adminhtml">
    Sevenbits_Demo_Adminhtml
</demo>

make that look like this

<demo before="Mage_Adminhtml">Sevenbits_Demo_Adminhtml</demo>
1

You need to define layout for it

Create file for it app/design/adminhtml/default/default/layout/demo.xml

add below code to it:

<?xml version="1.0"?>
<layout version="0.1.0">
    <adminhtml_demo_index>
        <reference name="content">
            <block type="demo/adminhtml_demo" name="demo" />
        </reference>
    </adminhtml_demo_index>
</layout>

Also you need to add below code in config.xml file between <adminhtml></adminhtml>

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

Also give the link

<action>adminhtml/demo</action> instead of <action>Adminhtml/demo</action>

  • ok @prashant let me check – Vasim Shaikh Jul 18 '16 at 11:16
  • I have already demo.xml – Vasim Shaikh Jul 18 '16 at 11:17
  • Where it is located and what is inside it? – Prashant Valanda Jul 18 '16 at 11:18
  • its in frontend – Vasim Shaikh Jul 18 '16 at 11:18
  • I just added into adminhtml – Vasim Shaikh Jul 18 '16 at 11:19

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.