Reputation: 31337
Let's say you have a homepage that it's different (but not totally) from the rest of your site pages.
It's clear that we should create a layout for all secondary pages.
It's not so clear, however, how should we deal with the homepage here?
Because, if we make a conditional on the layout, telling something like: If it's not the home page, use this, otherwise use that.
It's not at all friendly to maintain if, on the future, we have other pages that should also be different then homepage. If not this, and if not that, and if that, then ... :s
I believe it's on this situations that design patterns exist - but wish one?
My question is: What would be a nice way to handle this? Should we have two layouts defined? One for homepage and another for all the others?
Upvotes: 1
Views: 355
Reputation: 8218
Yes definitely make two layouts. Override the layout to use in case of the homepage in the action function in the controller:
$this->layout = '//layouts/home';
Upvotes: 2