If my whole site is using the default.ctp layout specified in apps/view/layouts/default.ctp, how do I change only the home page layout to use homepage.ctp and leave the rest of the site using default.ctp?
If my whole site is using the default.ctp layout specified in apps/view/layouts/default.ctp, how do
Share
Copy the
/cake/libs/controller/pages_controller.phpinto your/app/controller/dir and do either of the following:display()to switch the layout if ‘home’ is requested:if ($page == 'home') $this->layout = 'homepage';home()method (or named however you like) in which you set$this->layoutand re-route the/route in/app/config/routes.phpto use this new method.Edit:
In summary, you need some custom method in which you’ll set
$this->layout = 'homepage', that’s all. You can do this in any of your controllers at any point, reusing thePagesControlleris just the most convenient and conventional way to do it in Cake.