1

I took steps according to this article but the newly created link displays the "text block" on the front-end instead of back-end. http://alanstorm.com/magento_admin_controllers/

enter image description here

Here is the front-end page where the link redirects

Can anyone help me understand what's the problem? Greatly appreciate your help guys!

3 Answers 3

0

First of all there is mistake in your config.xml. You have defined frontend and admin routers under frontend tag. Please correct and also share the path of your controller file so that I can help you more in this. Code for frontend router:

<frontend>
    <routers>
        <namespace_module>
            <use>standard</use>
            <args>
                <module>Namespace_Module</module>
                <frontName>whatever</frontName> <!-- http://dev.local/whatever/*/* -->
            </args>
        </namespace_module>
    </routers>
</frontend>

Code for admin router:

<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <namespace_module before="Mage_Adminhtml">Namespace_Module_Adminhtml</namespace_module> <!-- http://dev.local/admin/*/* -->
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>
6
  • thanks, I'll make corrections right away. The controller file location is ...\app\code\local\Cpstest\ProductComments\controllers\IndexController.php Mar 10, 2017 at 1:22
  • When I put "adminhtml" inside "admin" my "tab" next to "Sytem" in the backend doesn't show up. Mar 10, 2017 at 1:32
  • for creating menu you can create a seperate file with name adminhtml.xml in folder parallel to config.xml and place your code for creating menu there.
    – Gulshan
    Mar 10, 2017 at 1:37
  • Okay, I actually tried that in adminhtml.xml as well. And how can I redirect that link to back-end page instead of front-end? I just added a screenshot, please take a look. Mar 10, 2017 at 1:43
  • please check to which url it is redirecting. The url contains admin in it or not. Also put your controller under adminhtml folder and change path in your adminhtml.xml like adminhtml_controller so it will start working for admin
    – Gulshan
    Mar 10, 2017 at 1:46
0
  1. Reason for error is you didn't read Alan Storm guide properly.
  2. Secondly, you cannot add adminhtml node inside frontend node, magento is looking for adminhtml and admin nodes outside frontend and global node. Magento didn't found both nodes, so it's showing frontend 404 page not found error.
  3. Below is example from working extension, see properly and make changes on after understand it
  4. You must define ACL for each parent and child menu items, it's required.

<frontend>  
    <layout>
        <updates>
            <productcomments>
                <file>productcomments.xml</file>
            </productcomments>
        </updates>
    </layout>
    <routers>
        <productcomments>
            <use>standard</use>
            <args>
                <module>Cpstest_ProductComments</module>
                <frontName>productcomments</frontName>
            </args>
        </productcomments>          
    </routers>
</frontend>

<admin>
    <routers>
        <adminhtml>
            <args>
                <modules>
                    <module_name before="Mage_Adminhtml">Cpstest_ProductComments_Adminhtml</module_name>
                </modules>
            </args>
        </adminhtml>
    </routers>
</admin>

<adminhtml>
    <layout>
        <updates>
            <productcomments>
                <file>productcomments.xml</file>
            </productcomments>
        </updates>
    </layout>
    <acl>
        <resources>
            <all>
                <title>Allow Everything</title>
            </all>
            <admin>
                <children>
                    <productcomments translate="label" module="Cpstest_ProductComments">
                        <title>CPS Product Comments</title>
                        <sort_order>30</sort_order>
                        <children>
                            <prdcomments translate="title">
                                <title>Product Comments</title>
                            </prdcomments>
                        </children>
                    </productcomments>
                </children>
            </admin>
        </resources>
    </acl>
</adminhtml>
2
  • Thanks for your reply, but I updated my question and the issue is different. There is no 404 error. Mar 10, 2017 at 17:46
  • Although you cannot add adminhtml and admin nodes inside frontend. And it get frontend controller with some route, so there is no 404 error. You just rename frontend controller file name only and no change in config.xml, then click Product Comments link in admin
    – Ananth
    Mar 11, 2017 at 3:11
0

Alright, at last I was able to resolve this issue using this article.

Hope That helps someone!

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.