• Call me on: +31 (0)6-44082344
  • Send us Mail
  • Subscribe to our RSS Feed
  • Search Site

SanderSluis.com

  • HomeIntroduction
  • ResumeMy skills
  • ProjectsMy work
  • BlogMy opinion
  • ContactGet in touch with me

You are here: SanderSluis.com / Magento / Changing the page template in a Magento controller

Changing the page template in a Magento controller

11 Nov 2011 / 6 Comments / in Magento/by Sander Sluis

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).

6 Responses to Changing the page template in a Magento controller

  1. Shasi Kanth Dulipalla says:
    May 31, 2017 at 13:07

    Thanks for the code example… very useful 🙂

    Reply
  2. college girls says:
    July 6, 2017 at 09:47

    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.

    Reply
  3. Humminbirdptc says:
    December 11, 2020 at 15:42

    commonly associated with

    Reply
  4. Avalanchezqw says:
    December 13, 2020 at 07:13

    handwritten by the author.

    Reply
  5. Backlitcfd says:
    December 13, 2020 at 18:14

    The most common form

    Reply
  6. Fortressrlt says:
    January 5, 2021 at 22:08

    antiquities. These are the Egyptian papyri

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Pages

  • Blog
  • Contact
  • Home
  • Projects
  • Resume

Social

Pages

  • Blog
  • Contact
  • Home
  • Projects
  • Resume

Recent Posts

  • Loading (multiple) products by tag name in Magento
  • Changing the page template in a Magento controller
  • Hello world!

Categories

  • Magento
  • Uncategorized

Hire me!

Call me on: +31 (0)6-44082344
© Copyright - SanderSluis.com - Wordpress Theme by Kriesi.at
  • scroll to top
  • Send us Mail
  • Subscribe to our RSS Feed