I have a contrib module which provides the abillity to swtich the theme based on a context. However, I can't seem to get the theme to be set outside of an init() hook. See the issue in the project queue here:

http://drupal.org/node/559410#comment-2055478

Does anyone know if its possible to set the drupal theme during a hook_context_page_reaction() hook (context_theme_context_page_reaction() in this case)

Is this possible?

Note that this method is very poorly documented right now, and isn't listed at http://drupalcontrib.org/api/search/6/context?

Comments

tronathan’s picture

User Asiby sent me the following:

Message:

I think I found it.

Check this out ...

http://api.drupal.org/api/global/custom_theme/6

If you set the following variable inside hook_init ...

global $custom_theme;

... then it will happen before any template is rendered. But most importantly, at the time hook_init is being called, all modules are loaded and ready to rumble.

I will try it out and let you know. But I will need the rest of your code that integrate with the context module so it will all be manageable in the admin interface.

Please respond.

Cheers

Asiby

abdoulaye.siby@gmail.com

But we need to be able to set the variable during hook_context_page_reaction() - So this approach won't work.

How can we set the theme during hook_context_page_reaction()? (How are these sorts of chicken-egg bootstrap situations usually worked around in drupal?)

pasqualle’s picture

The theme change can't be a reaction, because at reaction state it is too late to change the theme. It must be done in hook_init().
So you can't use some of the special context conditions, but you can use quite many. see http://drupal.org/project/themekey

pasqualle’s picture

socialnicheguru’s picture

integration with themekey just as a suggestion
http://drupal.org/project/themekey

yhahn’s picture

Status: Active » Closed (duplicate)