Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


share|improve this question
up vote 4 down vote accepted

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">
share|improve this answer
Works like charm! +1 – balanv Mar 8 '14 at 13:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.