Hi,
How can i change the theme at run time. For example for node/1 i need garland while for node/2 i need minelli theme. Can anyone tell how it is achieved or send code snippets ?

Thanks

Comments

ionut.alexuc’s picture

Use hook_init.
Here you can set:

global $custom_theme;
$custom_theme = $theme; // where $theme is your theme
ubdr’s picture

I need to implement it in Ubercart's catalog module. I put your code in function theme_uc_catalog_browse of catalog module, but it did not worked....................................

aangel’s picture

In D7 use hook_custom_theme() or for more granularity set theme callbacks.

See:
http://api.drupal.org/api/drupal/developer--globals.php/global/custom_th...
http://www.snipplr.com/view/49976/

Bagz’s picture

This is what I have used before, which changes the theme based on what is in the url. This code needs to be in your module file.

/**
* Implementation of hook_custom_theme().
*/
function yourmodule_custom_theme() {
	if (arg(1) == 'something') {
	  return 'mayo';
	}
}
ubdr’s picture

Hi Bagz ,
Is 'mayo' the theme's name?

Bagz’s picture

Yes, replace 'mayo' with the name of the theme you want to use. The theme must be one of the enabled themes.