1

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?

See

class Mage_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action
{
    protected function _outTemplate($tplName, $data=array())
    {
        $this->_initLayoutMessages('adminhtml/session');
        $block = $this->getLayout()->createBlock('adminhtml/template')->setTemplate("$tplName.phtml");
        foreach ($data as $index=>$value) {
            $block->assign($index, $value);
        }
        $html = $block->toHtml();
        Mage::getSingleton('core/translate_inline')->processResponseBody($html);
        $this->getResponse()->setBody($html);
    }

    public function loginAction()
    {
        if (Mage::getSingleton('admin/session')->isLoggedIn()) {
            $this->_redirect('*');
            return;
        }
        $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

1

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

0

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

Thanks

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.