1

I need to create a custom admin module and I want to use a template file instead of using a grid. Can someone give me an example of how I would do this. Not sure if it is possible to do this in the controller or if I still need a block and then reference the template there?

1 Answer 1

0

Based on ModuleCreator patterns we all have made Admin modules with grids, forms, etc... but, at the end, admin environment is like the frontend

Asuming you are familiar with grid block structure & classical Admin modules. You have a controller, which usually calls something like

$this->loadLayout();
$this->renderLayout();

Then, you define in your layout something like

<reference name="content">
    <block type="yourmodule/adminhtml_yourmodule" name="yourmodule" />
</reference>

Where your grid should load, etc...

You only need to extend Mage_Adminhtml_Block_Template block in your block yourmodule/adminhtml_yourmodule instead of extending any widget class (as they load their own templates), and then assign a template (in the block constructor, or in the layout, as you preffer)

Examples

Define template in block constructor

public function __construct()
{
    parent::__construct();
    $this->setTemplate('xxx/xxxx.phtml');
}

Define template in layout

<reference name="content">
    <block type="yourmodule/adminhtml_yourmodule" name="yourmodule" template="xxx/xxx.phtml"/>
</reference>

As you are extending Mage_Adminhtml_Block_Template you'd place your template into app/design/adminhtml/XX/XX/template folder

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.