Changing the Theme based on variable

mcoers - June 10, 2009 - 18:51

I am trying to change the theme based on where in the world a person is.

Currently I can use ThemeKey to change out the Theme based on the user's language, but that solution won't work for me because the client has different product mixes for different countries. So, although both U.K. and U.S. both speak english, I need to show them different websites.

I have a function I've written that basically pulls the user's country from a database based on IP range. I can put this information into a variable. So, how do I modify the theme based on the contents of that variable?

Maybe other people have a

sapark - June 10, 2009 - 20:48

Maybe other people have a better idea to switch out the theme, but here's an idea for adding a class or id to your current theme, then you can use css to make the theme different.

In tempate.php or even node.tpl.php, page.tpl.php, one of those somewhere, there's a place to put body class or id -- put your variable as an id, then theme:

#uk body {
}

or something like that.

Hope that helps.

...

Jeff Burnz - June 10, 2009 - 22:42

Hmmm, I'd take a look at the Switchtheme modules code and http://api.drupal.org/api/function/init_theme/6, could be be some pointers there, basically you have set the $custom_theme variable and somehow save it in the session for the user.

 
 

Drupal is a registered trademark of Dries Buytaert.