I'd like to create a module that detects some properties of my web site visitors and use those to select a theme. Just as an example, to clarify my needs: suppose I have two themes set up called 'extern' in /sites/all/themes/extern and one called 'intern' in /sites/all/themes/intern. So one for external users and one for internal users. I know the IP addresses of my internal users (note that they might not be on my intranet alone). Depending if the IP address is in a predefined list, I would like my site to use the 'intern' theme and otherwise use the 'extern' theme.
In my module, what functions/hooks to I need to override, what do I need to change in the passed parameters or is there another way to go about this, like call module-based functions from template.php? Each of the theme's might have a different set over overriding template files, so my 'intern' theme might have a page.tpl.php only and my 'extern' theme might have both a page.tpl.php and a block.tpl.php or even another set of template files.
I'd like to implement this using the standard PHPtemplate engine and I do not like to fork any existing modules please.
Thanx.
Comments
Check out Themekey plus
Check out Themekey plus ThemeKey Properties.
Enable all four modules (Themekey has includes 3)
Visit "Site Configuration" > ThemeKey
Click the "Settings" tab, under "Properties" find and select "system:remote_ip", save changes
Optionally enable debugging information under the "debug" tab.
Back to "Site Configuration" > ThemeKey
Click the "Properties" tab, add IPs as needed, selecting the appropriate theme.
If you want to check a range
If you want to check a range of IPs you can enable "system:dummy" then under "Properties" make a rule for system:dummy where value "dummy" (always true) and add an additional conditions that uses regex, something like
system:remote_ip~/^127\.0\.[0-9]{1,3}\.[0-9]{1,3}$/
(that will match any IP starting with 127.0)FOudn hthe solution
Thanks a million. The module showed me what I wanted to know. I now know that in my module's hook_init() function I can set the global $custom_theme variable to the name of the theme I want to show for those users. To helpe others:
You do realize you are
You do realize you are setting $useTheme and using $use_theme?
Just an example
Sorry, yes, a typo. But this is just an example.
Easy way for Drupal 7
http://drupal.org/node/224333#custom_theme