In magento 1.7.x and above login template is set in the layout xml file, so to change template is very easy.

How to achieve that in 1.5.x or 1.6.x where there are no layout xml and block and template is created on the fly in the controller?


class Mage_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
    protected function _outTemplate($tplName, $data=array())
        $block = $this->getLayout()->createBlock('adminhtml/template')->setTemplate("$tplName.phtml");
        foreach ($data as $index=>$value) {
            $block->assign($index, $value);
        $html = $block->toHtml();

    public function loginAction()
        if (Mage::getSingleton('admin/session')->isLoggedIn()) {
        $loginData = $this->getRequest()->getParam('login');
        $data = array();

        if( is_array($loginData) && array_key_exists('username', $loginData) ) {
            $data['username'] = $loginData['username'];
        } else {
            $data['username'] = null;

        $this->_outTemplate('login', $data);

2 Answers 2


Well, there's not much you can do. Obvious thing would to create a custom admin theme and just rewrite the template. But if you're planning to release a community module then it's obviously a bad idea.

Shame that they don't even give a name to that block in _outTemplate() method. Maybe it would be worth to check whether you can use an event adminhtml_block_html_before


At the end went into solution where I listed to pre HTML block event and replace template on the fly.


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.