Panels 2 Context Screencast

Jeff Miccollis and Young Hahn with DevelopmentSeed gave an excellent presentation at DrupalCon 2008 titled: Creating Custom Workflows for Drupal Apps: taking advantage of core hooks and context. The primary focus of this session was explaining the various methods of maintaining “context” throughout a Drupal site. In layman’s terms, this simply means a method of determining what content to display, or what actions to take based on where the user is currently located on the site. A simple example given was multi-lingual sites. A site may be in English by default, but if the user switches the site’s language to Spanish, then the there has to be some method in place to remember that this is the language this user has chosen, and we can assume that the user wishes to view the rest of the site in whatever language they have chosen. The language the user selected has become the “context” for the site. Now, any page that the user navigates to will be in Spanish, because the site has been implemented in a such a way as to remember the user’s chosen language.

Now, as you can probably tell, implementing a context for your site can sometimes be just as difficult as explaining what it is. In Drupal, there are several methods available to determine a context, but there are many pitfalls to look out for, especially if you are wanting to maintain a long-term context. Typically, we most often see context’s in use when setting what “section” of a site the user is on. We do this with either a thought out navigation structure (i.e. /galleries/album1, /galleries/album2). You will almost invariably find yourself resorting to looking at $node->type, arg(n), or using node_load() to determine what content to render. These can be handy for small, simple structured sites, but can quickly become a scalability issue on larger sites. You’ll find yourself having to return to append some more context to a switch statement in your template everytime a new section is added to the site.

So, that brings us around to Panels 2. At the presentation, Panels was suggested as a possible way to easily implement context and maintain it throughout a user’s experience. To clear up any confusion you may still have, sirkitree.net has posted this screencast about using Panels 2 Context.

You can read more about the session here and here.

Share This