What are Drupal 6 Panels Contexts
Note: Although this was written for D6 Panels, Panels continues to include contexts. I haven't tested the recent versions of Panels to see if anything has changed regarding contexts but perhaps this will provide a quick review before you get started.
There is a Drupal module called Panels. There is a Drupal module called Context. There is a feature in Panels called context. Panel's context and the Context module are not the same, not even close. According to Earl Miles, the developer of Panels: "In Panels, context is lingo for a wrapper around any significant object. By default, Panels supports 'Node', 'Taxonomy term', 'Taxonomy vocabulary', and 'User' as contexts." But what does that mean?
I recently purchased "Drupal 6 Panels Cookbook" from Packt Publishing, hoping to get all my context/relationships questions answered. I did learn a couple things from the book so it wasn't money wasted but it didn't answer all my questions. So I did what I often have to do, I starting clicking and observing what happens. This article is what I have figured out. I hope you find this useful.
What is a Panel context?
In order to answer this question, you need to know what a panel is. Simply put, it is a set of regions (not theme regions) where you can insert different types of content (node, blocks, fields, etc.) such that they are arranged on a page differently than the theme would have intended. The content you can add to your panel page, is organized in Panels as follows:
- page elements
- new custom content
- existing node
- Views (only if you have any views made).
But what if you want more content? The answer, add a context. A context gives you access to additional content. A better name, IMHO, would be "Include Other Content" or something like that.
Basically, if you want access to content that is not on the default content list, you need to add one or more of the following contexts:
- node add form
- node edit form
- taxonomy term
- taxonomy vocabulary
For each type of content you add, you get additional content options. Depending on which context type you add, you might get the option to create relationships as well. Below is a brief description of what each context type will get you.
If you add a node context to a custom Panel page (Panels' Node template has Node content by default), you are adding a specific node (e.g., node/34). It isn't obvious what you have just enabled until you try to add content to a panel pane. From a panel pane, click add content. In addition to what you had before (see list above), you now have a Node content.
Within the Node content type, you have all the fields and attributes (comments, terms, links, create/update dates, author, node type description, attachments, etc.) for that node. If you select one of the node contents, you will get the content for the specific node being referenced in the node context.
You don't have to add a node context to show a node in a panel pane. But if you want access to all the node parts, you do need it. If you want to add specific parts from multiple nodes, you need to add a context for each node.
Node Context Relationships
When you add a node context, you get the option to add additional control by using Relationships. The node context comes with these relationships: term from node, multiple terms from node, node edit form from node, node author, book parent node add form.
Node Add Form
When you add this context, Form content is added. The form elements (menu, category, comment settings, input format, author info, etc.) are made available but not the individual form fields. General form gets you the entire node/add form (fields and settings). When you add the add form context, you do not get relationships.
Node Edit Form
Just like Node Add Form, when you add this context, Form content is added.
Node Edit Form Relationships
When you add edit form, you get relationships: term from node, multiple terms from node, node edit form from node, node author, book parent.
When you add this context, you are adding one term from one vocabulary. Taxonomy term content is added to content. You don't get the term you added, you get the option to list the related terms and/or the term description.
Taxonomy Term Relationships
When you add edit form, you get relationships: parent term.
This context adds Vocabulary to the content options. Your option is to list the vocabulary terms. When you add this context, you do not get the relationships.
To be honest, I don't have this one figured out. When this context is added, I don't see any content options added. Also, when you add token, you do not get relationships.
This context adds user related content (user image and default profile). If you have profile fields, you can show a field category but you cannot select one field from the category. When you add user, you do not get relationships.
First know that you do not have to have this to show a view block. This type of content refers to views with context displays configured. In order to add a view context, you need to have created one or more view context displays in an existing node. I tried this but nothing showed up. So back to the investigation for this one.
View Context Relationship
When you add view context, you get the relationship: node from view.
That's all I have for now. I hope this helps you. Next step is to dig further and experiment. As I learn more, I will let you know. If you can me and others understand further, please comment.