Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Overloading adminhtml index controller
 
mikewhitby
Member
 
Total Posts:  38
Joined:  2008-09-08
 

Hi all, I’m trying to change the theme of the logni box to the admin interface, so I decided to rewrite the indexController.php and add a setTheme command into my new one (I checked, the method works by adding it into the old controller, but I dont want to go rewriting the old controller).

The problem is that I’m getting a 404 when visiting /admin/ - which is good in one way as it shows my config.xml is doing something! But I can’t seem to get the rewrite working correctly, can anyone help?

My controller is in local/Adtrak/Adminhtml/controllers/IndexController.php, and looks like:

<?php
/**
 * Adtrak
 *
 * Overloaded adminhtml index controller, used to set the theme for the login page
 */

require_once 'Mage/Adminhtml/IndexController.php';

class 
Adtrak_Adminhtml_IndexController extends Mage_Adminhtml_IndexController
{
    
public function loginAction()
    
{
        Mage
::getDesign()->setTheme('airconproducts');
        
parent::loginAction();
    
}
}

And I’ve made a config.xml which looks like:

<?xml version="1.0"?>
<config>
    <global>
        <
rewrite>
            <
adtrak_adminhtml_login>
                <
from><![CDATA[#^/admin/$#]]></from>
                
<to>/adtrak_adminhtml/index/</to>
            </
adtrak_adminhtml_login>
        </
rewrite>
    </global>
    <
adminhtml>
        <
routers>
            <
Adtrak_Adminhtml>
                <use>
admin</use>
                <
args>
                    <
module>Adtrak_Adminhtml</module>
                    <
frontname>adtrak_adminhtml</frontname>
                </
args>
            </
Adtrak_Adminhtml>
        </
routers>
    </
adminhtml>
</
config>

Cheers!

 
Magento Community Magento Community
Magento Community
Magento Community
 
SimoneR
Jr. Member
 
Total Posts:  1
Joined:  2008-09-15
 

Hi,
I think the correct config.xml is:

<?xml version="1.0"?>
<config>
   <!-- 
Module version info goes here -->
    <global>
        <
rewrite>
            <
adtrak_adminhtml_login>
                <
from><![CDATA[#^/admin/index/#]]></from>
                
<to>/adminhtml/index/</to>
            </
adtrak_adminhtml_login>
        </
rewrite>
    </global>
    <
admin>
        <
routers>
            <
adtrak_adminhtml>
                <use>
admin</use>
                <
args>
                    <
module>Adtrak_Adminhtml</module>
                    <
frontname>adminhtml</frontname>
                </
args>
            </
adtrak_adminhtml>
        </
routers>
    </
admin>
</
config>

Hope it works!

Bye!

 
Magento Community Magento Community
Magento Community
Magento Community
 
mikewhitby
Member
 
Total Posts:  38
Joined:  2008-09-08
 

Thanks I’ll this tomorrow smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
profileo
Jr. Member
 
Total Posts:  5
Joined:  2009-09-14
 

doesn’t work

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top