By peterhessels on
What I want to accomplish is that when the user selects a group, the theme of that group is activated and will be active from that moment on, until he selects a "home" menu item. If he clicks the "home" menu item, the default theme should be used again for all actions until he selects a group again.
Any suggestions how to accomplish that?
Comments
_
You should be able to do this with the http://drupal.org/project/sections or http://drupal.org/project/themekey modules.
Not all right
Thank you for your repsonse. This module can be helpful but is not the solution to my problem, I think.
I want to use this "switch of theme" in combination with the organic groups: when I change to a group, the theme should change too. Only when I switch from a group to the main page, the general theme should be activated.
But: the theme module works on the basis of URLs. In the organic groups, most of the URL's start have "/og/" in the URL, so that would work. Not all URLs have that pattern (like when adding a user, requesting a list of users). I only want to switch back to the general theme after I hit the menu item "home". This cannot be done by the sections module, right?
I was thinking I could use only views in menu items, so I could name all URL's with a certain pattern. Then the problem is that a view using a variable (the organic group ID should be a variable) can not be called from a menu: it will say something like "The path '/og/users/%/list' is either invalid or you do not have access to it.". There is no way around that, is there?
Kind regards,
peter
_
The sections module accepts php for theme switching so you should be able to get any display criteria you want using snippets similar to the ones in the handbook: http://drupal.org/node/60317. The logic is going to be a little involved, because, as you correctly mention, not all pages are associated with a group so you'll probably have to use a bunch of conditions to get exactly the behavior you want. But as far as i can tell, it should definitely be possible.
To check the group context of a page, you can use og_get_group_context(), to check a user you need to look at $user->og_groups. I'm not sure exactly what the code should be, but you'll want to check for group context (just set the theme as desired) and for no group context. If no group context, you'll need to decide what you want to do for the pages -- ie if on '/user' pages you'll want to set the theme based on $user->og_groups.
Where to put the coding
Thank you for your suggestions. This looks very promising.
I was wondering where to put the code.
I was thinking of creating a variable in the views that I'm using in the menus and then setting the sections setting under "Activate section on the specific pages: ". Is that the right track?
Where can I find all the variables that can be used in $user and og_get_group_context()? I can't find them in general documentation.
Kind Regards,
Peter
_
The code should go in the page specific visibility settings for the section (select the php option).
To see what $user has, you can do
<?php print_r($user); ?>or (if you use the devel module)<?php dsm($user); ?>og_get_group_context() doesn't have 'variables' per say but to see the function look it up in the og module code.