Changing the page template in a Magento controller
I made this little snippet, that you can use to change the page template within a Magento controller:
1 2 3 4 5 6 7 8 |
public function indexAction() { $this->loadLayout(); if((bool) $this->getRequest()->getParam('ajax')){ // ?ajax=true $this->getLayout()->getBlock('root')->setTemplate('page/ajax.phtml'); //changes the root template } $this->renderLayout(); return $this; } |
This particular example changes the template to ‘page/axjax.phtml’ if the ‘ajax’ get parameter is set to true (?ajax=true).
Thanks for the code example… very useful 🙂
You could certainly see your skills within the article you write.
The sector hopes for even more passionate writers such as you who are not afraid to mention how they
believe. At all times follow your heart.
commonly associated with
handwritten by the author.
The most common form
antiquities. These are the Egyptian papyri