I would like to create a simple custom module which could use $custom_theme to override current theme. In drupal 5 I would have made a custom module and put something like this into custom_module_menu:

>
f($may_cache){
} else{
	$custom_theme='some theme';
}

How would I do this in Drupal 6? What hook should I use? (there could be modules for this but I just want to keep it as simple as possible).

Tnks!

Comments

wpanssi’s picture

I tried the menu -hook:

function my_module_menu(){
global $custom_theme;
$custom_theme="bluebreeze";
}

But this doesn't do anything..

--
http://www.sitemedia.fi

wpanssi’s picture

Clearing cache won't help, neither does adding the call of init_theme() after defining custom_theme..
According to Drupal 6 API $custom_theme exists.. So ANY ideas? Has somebody used $custom_theme succesfully to override a theme?

--
http://www.sitemedia.fi

jsaints’s picture

Try disabling simplemenu... they see if $custom_theme works.

drupalfever’s picture

How to switch theme depending on user role:

Create a custom module and copy & paste the following:

/**
 * Implementation of hook_init().
 */
function mymodule_init() {
  global $custom_theme, $user;
  if (in_array('my special role', $user->roles)) {
    $custom_theme = 'mytheme';
  }
}

You have to replace:
mymodule => with your module name
my special role => with the name of the role that your users will need to have in order for them to see a different theme.
mytheme => with the name of the theme that you want to switch to