I have override an adminhtml controller Mage_Adminhtml_System_ConfigController. I am trying to load a .phtml file from one of my Custom module as like below

$block = Mage::app()->getLayout()->createBlock('custommodule/blockname')->setTemplate('custommodule/file.phtml');

$html = $block->getHtml();

But since i am in an Admin controller, the system tries to setTemplate in under


But the file i want to load is under


The system throws error like, the template path does not exists. I am aware that this is happening since we are in an admin controller, and the system tries to load the admin layout file. Trying to see the possibility of doing this.

Suggest me a solution.

Note : This code works well when i call it from a front end controller.



Try to set frontend area for your block before setting template

$block = Mage::app()->getLayout()

The same you can also do in layout xml file

<block type="custommodule/blockname" template="custommodule/file.phtml">
    <action method="setData">
  • Works like charm! +1 – balanv Mar 8 '14 at 13:32

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.