// DRUPAL 6
function mymodule_init(){
global $custom_theme;
$custom_theme = 'garland';
}
// DRUPAL 7
/**
* Defines a theme callback function per registered path.
*/
function mymodule_menu_alter(&$items) {
$items['node/%node']['theme callback'] = 'mymodule_default_node_theme';
$items['node/%node/edit']['theme callback'] = 'mymodule_edit_node_theme';
$items['node/%node/edit']['theme arguments'] = array(1);
}
/**
* Theme name callback: without parameters.
*/
function mymodule_default_node_theme() {
return 'garland';
}
/**
* Theme name callback: with parameters.
*/
function mymodule_edit_node_theme($node) {
return $node->type == 'page' ? 'seven' : mymodule_default_node_theme();
}
/**
* Use hook_custom_theme() if the choice of theme doesn't depend on the path.
*/
function mymodule_custom_theme() {
//Example: Changes the theme name depending if the user has a special role or not.
global $user;
if (in_array(variable_get('mymodule_special_role', 0), array_keys($user->roles))) {
return 'bartik';
}
}