Changing only the home page layout in cakephp
-
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?
-
Answer:
Copy the /cake/libs/controller/pages_controller.php into your /app/controller/ dir and do either of the following: Add a line towards the end of display() to switch the layout if 'home' is requested: if ($page == 'home') $this->layout = 'homepage'; Create a home() method (or named however you like) in which you set $this->layout and re-route the / route in /app/config/routes.php to 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 the PagesController is just the most convenient and conventional way to do it in Cake.
Bradley at Stack Overflow Visit the source
Related Q & A:
- How do I set it up to open Yahoo at my mail page, instead of the home page?Best solution by Yahoo! Answers
- How to you switch back to the old yahoo home page. I hate the new home page?Best solution by Yahoo! Answers
- How can I make a page my home page?Best solution by Yahoo! Answers
- Why does Yahoo home page keep changing?Best solution by Yahoo! Answers
- How do I make mail page home page?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.