I've got Panels working with Organic Groups (d7) using the documentation about "Drupal 7 Panels integration guide (OG 7.x-1.x)". It describes how to create a node panel that detects when you are viewing a group and then displays the layout accordingly.

This is great, however, I would now would like to create a new variant that would allow more specific customization of a specific group. Say for example I have a special group called "Education" that would need to arrange their group home page slightly different from others.

I have made some adjustments to what I think would do the trick, but it does not work. Here is what I have done:

  • Cloned the original varient from the documentation
  • Under Contexts, added a new context "Organic groups group" and specified the group id of the "Education" Group
  • Under Selection rules, added a new "Context exists", and selected my context created in the above step
  • Made some adjustments to layout
  • Saved, and reordered variants to make this one come first

This worked.... however for some reason it applies to all groups not just to my "Education" group. Again, I would like to have a custom layout for my "Education" group, and have a default layout for the rest. I'm still new at panels, can anyone spot what I'm doing wrong based on my description?

up vote 3 down vote accepted

You could also try specifying by url string "education/*" or even node ID instead.

  • I tried to set up a context based on node id, then set the "context exists" under selection rules, but the same behavior is still present (this variant is applied to all groups). This behavior doesn't make sense to me. Is this the right way to go about setting this up? – bkildow Sep 1 '11 at 13:29
  • I think I had a misunderstanding of what context really does. I didn't see the node id option, but the url string worked like a charm. – bkildow Sep 6 '11 at 12:43

My guess is that your contexts are set to "only one criteria must pass" instead of "all criteria must pass". To change this, go to selection rules and select "all criteria must pass" at the bottom, then save.

How it's meant to work. Selection rules are designed to work for group content selection like this:

  1. In your Panel variant's "Selection rules" section, add the selection rule "Node : groups audience field" (or whatever your og_group_ref field is called there).

  2. In the form that appears, select the group that you want to create the group default panel for.

  3. If your group may contain several node types, configure "Only one criteria must pass." in your selection rules section and repeat steps 1-2 for each node type.

This method is however effectively blocked by Drupal issue #2242511 at the moment. (The issue thread mentions a workaround, but it's impractical.)

Your misunderstanding: two things called context. In total, it seems you (like myself) had misunderstood what a "context" is in Panels. It's a way to pass in arguments to the content elements of a panel, similar to what "contextual filters" do for Views. The "Context exists" use is just a side use of this, which can be used to check if a certain argument is supplied at all. "Context exists" has nothing to do with "context is set" of the context module – the panels and context modules have nothing to do with each other, as there is no dependency between them. It's just two different things called "context" ...

More options. For a discussion of other working and non-working alternatives to create group-specific default panels in Drupal 7, see my blog post about it.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.