
This article explains how to switch your theme. In our example we will switch the theme if one of the fields of our node has a certain value.
Use hook_init() [2] to accomplish this.
<?php
function thuis_sanitech_extra_init() {
if (arg(0) == 'node' && is_numeric(arg(1))) {
$node = node_load(arg(1));
global $user;
if ($node->field_theme_keuze[0]['value'] == 1) {
//load appropriate theme
$user->theme = 'affaires';
init_theme();
}
if ($node->field_theme_keuze[0]['value'] == 0) {
//load appropriate theme
$user->theme = 'sanitechniek';
init_theme();
}
}
}
?>Links
[1] https://dominiquedecooman.com/blog-topics/theming
[2] http://api.drupal.org/api/function/hook_init/5