Note: This tutorial uses some ThemeKey properties from an additional module called ThemeKey Properties.
In this tutorial you'll learn how to define ThemeKey rules and how to cascade them to achieve sophisticated rule chains.
The use case is to use a different theme during content creation for premium users, e.g., you don't want to show advertisements or you want to show some advanced help blocks ...
Therefore you created two user roles called "premium user" and "standard user". Using ThemeKey it's easy to create a rule that switches the theme if a user's role is "premium user":

Similarly, we can also create a rule that switches the theme if a content creation form is requested. To do this for any kind of content we use ThemeKey's drupal:path property and its wildcard feature:

But having these two separate rules is not what our use case describes. To implement our use case, we have to cascade or "chain" both rules. By dragging on the cross icon in front of a rule, you can move any rule up and down or indent it. The chain we need should like this:

Now using this chain, ThemeKey only switches the theme on content creation forms if the current user's role is "premium user". Non-premium users will use the current standard system theme.
You might have noticed that the theme select box disappeared for the first rule as you indented the second one. That's because both separate rules became one.
Now it's possible to extend our chain to use another dedicated theme on content creation forms for "standard users".

If you have more than these two roles in your system and you simply want to use one theme for premium users and another for non-premium users, on content creation pages, you don't need to add one rule per role, as described above. In this case, it's easier to change the latest rule we added and say any other rule other than "premium user", using ThemeKey's not operator "!".

Now that we have implemented our use case using chained ThemeKey rules, you can add more rules to ThemeKey's Rule Chain to implement different use cases. The only decision you have to make is the order the rules are checked by ThemeKey on every page request. To demonstrate this, let's add another rule that switches the theme if the user uses an iPhone to access your page.

What happens now is that ThemeKey switches to a special theme for iPhones whenever the user accesses your page using such a device, because ThemeKey stops processing the rules if a rule, or one set of chained rules, matches. This means that content creation forms are shown using the iPhone theme, regardless of the role assigned to the current user.
I think that's a good choice. If you move the iPhone rule below the chain for the content cration form, these forms will use the configured themes even on the iPhone, which might not be suitable for displaying them.
If you'd like to treat node creation forms differently, even on the iPhone, you should "chain" a dedicated set of rules for that.

Have Fun!
Comments
I have tried to do it on
I have tried to do it on Drupal 7.
This tutorial did'nt work for me. I have enabled all my themes, assigned permissions and UI settings.
The Edit page shows only one option: don't switch the theme
Could you update this tutorial for 7.x-1.0 version?
Great project! Awsome idea! Thanks
You're right. The tutorial
You're right. The tutorial targets ThemeKey 6.x.
Using ThemeKey 7.x on Drupal 7 you have to configure the "Selectable Themes" at "/admin/config/user-interface/themekey/settings/ui" additionally.
Hi, I would like to know some
Hi,
I would like to know some more information about using this module it looks really amazing. I searched for the documentation/ Tutorials but only found how to setup the Theme Switching Rule Chain but i dont know how to configure/settings part of the module. Please help me here ..,
I am using two themes for a website with multiple books in it. I want to display different themes for different books when anonymous user flips over to different books it should automatically change to the concerned theme. how can I achieve this using this module
expecting your guidance
Thanking you in advance
vignesh
@vignesh: see my comment on
@vignesh:
see my comment on http://drupal.org/node/633194#comment-4365984
In my D7 I have added a
In my D7 I have added a rule:
Change theme for node:type=blog to garland.
All themes are made selectable.
When I navigate to mysite.com/blog nothing happens.
Please help!
rolandk
see
see https://drupal.org/node/1229456
Hallo, danke für die
Hallo,
danke für die Videomitschnitte. Hab leider wenig erkannt von der Leinwand des 2011 Vortrages, war leider alles verschwommen. Gibt es ein Videotutorial dazu zu kaufen, das mir Schritt für Schritt zeigt wie ich das Modul ThemeKey anwende, um ein mobiles Theme oder auch anderes Theme für Splittests zu erstellen in einem einzigen Drupal und dann zu switchen?
Ohne Schritt für Schritt Video - hab auch schon vergeblich bei YouTube gesucht - ist das für mich als Musikerin schwer umsetzbar, obwohl ich schon alle meine Seiten mit Drupal selbst gebaut habe.
Viele Grüße
Kat
How to create a flash intro
How to create a flash intro page using Themekey
Hier gibt es ein
Hier gibt es ein Video:
http://mustardseedmedia.com/podcast/episode52
Post new comment