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
adminhtml/default/default/template/custommodule/file.phtml
But the file i want to load is under
frontend/default/default/template/custommodule/file.phtml
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.
Thanks
Best Answer
Try to set
frontend
area for your block before setting templateThe same you can also do in layout xml file