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.

asked Jul 18, 2016 at 11:00

2 Answers 2

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>
answered Jul 18, 2016 at 11:03
1
  • still same issue Commented Jul 18, 2016 at 11:08
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>

answered Jul 18, 2016 at 11:13
14
  • ok @prashant let me check Commented Jul 18, 2016 at 11:16
  • I have already demo.xml Commented Jul 18, 2016 at 11:17
  • Where it is located and what is inside it? Commented Jul 18, 2016 at 11:18
  • its in frontend Commented Jul 18, 2016 at 11:18
  • I just added into adminhtml Commented Jul 18, 2016 at 11:19

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.