The recent solution is not really working for me because I want to use a special template for many pages. (Perhaps a solution could be to use the php-switch Edi described for a category, but I don't know how to implement this …)
There is a possibility to use the template setting for the pages and also for the categories. The value is stored in the page/category, you just have to add it to the theme. I use it productively for a theme of mine.
The variables are called:
- $page->template()
- $page->categoryTemplate()
I have built the distinction in the index.php of the theme:
Code: Select all
switch ($WHERE_AM_I) {
case 'page':
if ($page->template()) {
include(THEME_DIR_PHP.$page->template().'.php');
} elseif($page->categoryTemplate()){
include(THEME_DIR_PHP.$page->categoryTemplate().'.php');
} else {
include(THEME_DIR_PHP.'page.php');
}
break;
default:
include(THEME_DIR_PHP.'home.php');
break;
}
The only limitation is that you have to enter the template exactly written correctly by hand. There is no selection option. To avoid errors I use therefore for this among other things the categories. Once set in the config, the appropriate template is always used. But if you can use that via the categories is a very individual question, depending on the content structure & requirements.
The check for $WHERE_AM_I I have rewritten as a switch, because I like to use this variable for individual template & plugin solutions and thus can use any number of "cases" without getting stuck in the if-then-else loop.