By jarek foksa on
I need a Drupal 7 module that would allow anonymous users to switch theme by entering specific URI query string. For example:
- www.mysite.com/&q=garland would switch to Garland
- www.mysite.com/&q=seven would switch to Seven
Could you point me a built-in Drupal functions that could be used when writing such module? I need at least:
- a function to retrive query string for currently rendered page ($_GET['q'], right?)
- a function that would append a specific query string to all links on currently rendered page
- a function that would switch theme for currently rendered page
Thanks!
Comments
switchtheme module
It's probably worth taking a look at the switchtheme module - http://drupal.org/project/switchtheme - it might not do exactly what you want, but the code should give you some pointers on how to do what you are after ...
Mike,
Computerminds offer Drupal development, consulting and training
Yeah, there is also ThemeKey
Yeah, there is also ThemeKey module, unfortunately both of them are not compatible with Drupal 7.
Here is my progress. I
Here is my progress. I discovered
hook_custom_theme()function. I called my module "switcher", I enabled Garland theme (though it's not the default theme) and I have placed following code in switcher.module file:I expected it to switch the current theme to Garland, but it does not seem to work. When I refresh the site the theme does not get switched. But I can see the "TEST" status message, so the module must have been installed correctly.
Update
It works! I just had to clear the cache.
Now I just have to append
Now I just have to append a query string to all links.
Example: If user entered the page by clicking on "mysite.com/node/1?theme=garland" link, then all links on this page should have "?theme=garland" query string appended.
Any ideas how to do this?
Interesting, have you found a
Interesting, have you found a way to do this?
Yeah, but I coudn't figure
Yeah, but I coudn't figure out how to do this with PHP so I used JavaScript. You can download the module from here. The implementation is not very elegant, but it works:
- http://demo.kiwi-themes.com/drupal-dev/?theme=garland
- http://demo.kiwi-themes.com/drupal-dev/?theme=tarski
- http://demo.kiwi-themes.com/drupal-dev/?theme=titan
BTW, Drupal 7 version of the
BTW, Drupal 7 version of the ThemeKey module is now available.