/ Published in: PHP
Important: this snipplet has moved to Github.
Expand |
Embed | Plain Text
// 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'; } /** * 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; return 'bartik'; } }
You need to login to post a comment.
