In Panels, Context is lingo for a wrapper around any significant object. By default, Panels supports 'Node', 'Taxonomy term' (and terms as mentioned above), 'Taxonomy vocabulary', and 'User' as contexts.

These contexts can get into a display in more than one way; right now, there are three ways that a panel page can acquire a context:

1) Via arguments. Under the 'advanced' tab in panel pages, there is a list of possible arguments. Once added to the page, the argument is converted to a context, and this context becomes available for panes to use. Also, arguments can be selective; the node ID argument can restrict itself to a node type; if the node ID given is not a node of one of these types, no context will be created. (And the argument can tell the system to 404 or just let it pass and the panel will run without that context).

2) Simply added. Under the 'advanced' tab (currently in -dev only and will be in Alpha14), there is a group a Context section. Clicking 'add' on one will bring up a dialog, where a specific object is selected. For example, when adding the Node context, the popup will provide the autocomplete to select a node by title or nid.

3) By relationship. Once a context is in a page via any method, more contexts can be added by relationship. For example, if I have a 'node', I can extract one or more 'term' contexts from it by the obvious relationship. As well, I can come up with another node via 'book parent'. I can come up with a user reference from a node too, by getting the author. Once CCK integration is in place (currently it is not) I could come up with nodes via node references and users via user reference.

Once you have contexts in the system, this allows panel panes to appear that require contexts. For example, there is a 'node content' pane that simply renders a node. Without a node, it can't do anything; this context is required. If a node context isn't in the system, you won't even see this as an option. But once the display has a node context available, Panels will allow you to add the node context pane. Even better, if you happen to have multiple node contexts, in the popup to add the pane, you can choose which node context to render.

Panels will also let you convert the contexts into Views arguments, so that you can more visually control how Views get their data; you will no longer need to use the %1 and @1 methods of giving information to Views.

Here's a random example of what can be done

I can create a panel page which accepts a nid as an argument; that argument creates a node context. I then create a relationship which relates that node to the 'top level book', which means it will follow the book chain all the way up. I also create a relationship to the node's term in a specific vocabulary. On the display, I put the node content; to the side, I put the node content for the book parent, which is a description of the book. I also put the book navigation for the book parent, so that always is available. I also put the term description, so that it describes how this node is categorized. And I can also put a view of the term, so I can get links to the 5 most important nodes for that term.

Contexts, arguments, relationships and content types are all defined via plugins, which means they're in individual .inc files. But all plugins are also defined through module hooks. It is easy for a module to make additional contexts, arguments, etc available. In fact, specializing a 'node' argument so that it only accepts nodes with a certain criteria is something that makes a lot of sense.


Some of what I'm describing (method #2) is only in -dev right now, and will appear in Alpha14 when I release it, which should be Soon.

Hi Merlin,

The Panels 2 project is really earth shaking, and I am delving right in as a user and putting it through its paces, within the limits of my own skills. So I wrote a tutorial (or more like a log of what I did) called "OMG! Dynamic jCarousel with Themed Panels 2 pane node parts!" ( ) on the subject of theming a "node part" displayed in a panel. I have taken the "attached files" portion of a node override context and themed it into a dynamic jCarousel, and not only am I pleased with the result, but I am really blown away by all the possibilities; in terms of layout in Drupal being completely different from now on.

Two things: could you let me know if you think the overriding of the theme_panels_pane() function is a good way to go (am I on the right path, master?)?

And, please feel free anyone to take any useful parts for Panels documentation.

Thank you so much for your hard work, motorized by real need in the best Open Source tradition, and which gives so much back to the community.


Victor Kane

Hi Earl,

I love this. In particular I love looking forward to a day when we have nice method chaining objects (like jquery) and can traverse contexts by passing searches into getter functions of objects. I'm wondering how close you are with this to allowing contexts be a first class concept in Drupal (as opposed to being a feature of panels?)


That's a good question. Contexts are a first class object in Panels, for sure; but they also rely on the notion that everything is operating under the umbrella of a display.

Of course, if Drupal inherits that same sort of concept -- where everything operates under the umbrella of being a display -- then Drupal could do the same thing. There's a few questions that have to be answered, and Panels' code quality probably needs a lot of improvement. I'm still not happy with everything I've done; some stuff has been experimental and I wasn't happy with how it worked out.

Hey Earl,
Sounds very exciting, and I'll have to read over a few times to let it sink in since it's still a bit abstract to me at this point. Seeing some dynamic examples will probably help.

Otherwise, I have a feeling that you may be fielding a number of "So what is a context again..." type of questions on IRC.

I'll have to play around with this sometime soon -- Wim's demo site of Panels 2's Panel Style API looks great:

In case anyone is still a bit confused, I did a screencast about Panels 2 Context over at Check it out!

thanks sirkitree but that was the worst

please, can anyone tell me how to fill a panels page like this, using arguments:

i have a path like this: node/%

so if i use an url like node/42 i get the content with node id 42 in the first panel. but with an url like node/42/43 or node/42/43/44 i don't get contents in the other panels.
in the content settings i use "node context" -> node content -> node: node id
so how do i do that? i tried lots of different things and settings so gar, but nothing worked ...

just for informatiom, i'm not a programmer/developer but a designer (themer).

HI ,
Am writing a book on panels and have taken references from your website. If you permit i would use IT. I have duly mentioned your name as the source.

Earl, I'm sorry but still can't clearly understand Contexts through your writings. You just write in a too high level way skipping details about how one part of your phrase connect to the other part.

But thats OK, thats me.... I'm spending several days trying to understand it.

Contexts seem to me a region of memory where you define variables and then later Panes can access and publish them. Something similar to Tokens.

Add new comment