0

For instance I have a module My/Module (my_module) with a controller RenderController.php which has an action layoutAction. Is there a way that I can set a template for every action within the RenderController controller without having to do it for each individual "page" using layout xml.

I essentially want something like this:

<default> <reference name="root"> <action method="setTemplate"><template>page/1column.phtml</template></action> </reference> </default> 

but I don't want that template to be assigned for EVERY page in my theme, but only for those within my module, or even the specific controller (RenderController.php) within that module.

2 Answers 2

1

If you want to change the template of the root reference, you can try with something like :

public function yourSpecialAction() { $this->loadLayout(); $this->getLayout()->getBlock('root')->setTemplate('path/to/the/template/you/want')); // Do your process $this->renderLayout(); } 
0

You could look to add a custom layout handle in your controller then set the template in your layout xml file. For example in your controller in your action method look to add something like:

$this->getLayout()->getUpdate()->addHandle('my_awesome_handle'); 

Then inside for your layout xml file you can do the following:

<my_awesome_handle> <reference name="root"> <action method="setTemplate"> <template>page/1column.phtml</template> </action> </reference> </my_awesome_handle> 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.