Implementing ToMVC

I would have generic templates which could be included in other templates such as a various error pages, then you would have if ($user) {display user} else {include error.html.php}. Of course, generic errors aren’t always what you want.

For example, one place I’ve found good use for custom errors is on deleted products. A customer clicks on a link from google that takes them to a product which no longer exists. Rather than just displaying a 404, it’s better to display “Sorry, that product is no longer available, here’s some alternative similar products” and supply a 404 header so google doesn’t index the error page.

I disagree with this. The reason is that it’s useful to be able to include pages in other pages for example. I might have /news/latest which displays the latest 10 news stories in a list. It’s not unreasonable that I might want to pull this into a sidebar on another page and style it a different way. Same for contact forms and other specific reusable page elements.

Whether the layout is applied by the router or the front controller doesn’t really matter, but there needs to be somewhere that puts the routed mvc triad into a reusable layout. If it’s part of the templating engine, you then have trouble loading a template into a different layout (e.g. admins get a different layout to normal users)