Drupalcon SF Session: Context, PURL, & Spaces

20 Apr 2010
Posted by jcfiala

Talk given by Young Hahn - @younghahn on twitter.

This is a talk that focuses on three modules that were developed as part of Open Atrium.

Context triggers reactive behaviors on pages.

Basically, in the past putting content all on the same page was a pain. You have a snippet, say, that says 'This bit should show on blog pages', and you've got it spread throughout your site in half a dozen places. Context replaces this by having a system that asks 'are we in the blog section?'. There's also things like a global context, or a login context. (such as when an anonymous user is browsing).

Context is basically an additive system - a page can be in the global context, the blog section context, and the blog post context.

Note to self - do we need a page that lists all the blogs under all of their contexts for easier display?

Some demo of using Context 3, dragging blocks around and the like.

So, Organic Groups. OG has rules for which group you're in. And this usually works pretty well - although it's pretty session heavy. Problem is when you've got two different groups open in two browsers - you do something in tab a and group a, and then you try to do something in tab b and group b, and it turns out it actually happens in group a because of the session overriding the url. Oops.

So - PURL - the Persistant URL module. Purl puts data in different sections of the url and uses that to detect which group you're in - such as when flickr puts extra data into the path to identify which photoset you're browsing. Drupal does this in the language handling - a url like example.com/es/blog is put into the Spanish language by the 'es' section, and then drupal proper gets 'blog' as the arg(0) of the path.

Same thing in PURL, with groups. PURL can work with the user agent, domain, subdomain, path, or querystring. Managing news uses this for display node in a persistent query string. See, in addition to detecting the current change to the url for the variable, it also changes the urls being generated on that page to include the change, so that the data is persistent.

Demo of the Afganistan Election data, using PURL to define what fraud means - 600+votes and 100% or 590/95%.

Another module that uses PURL is themeswitcher, allowing people to choose their theme with a link press that sticks. (Demo, shows using path, then querystring)

So, on to spaces.

A space is a configuration environment in one condition - spaces overrides hold information that is provided to drupal when the space is active. Demo of the overrides page. For instance, showing overrides of translation strings for a group. "spaces custom text"

Spaces 3 can screw with your mind. Variable_get settings per space - controller plugin.
Patterns for combinations of settings for groups - spaces preset - set of overrides.

I was a little surprised at this point that he wasn't using drush when he was enabling modules and the like.

Demo of creating a new spaces preset, and then creating a new group that is based on it, customizing the group and then saving the changes back to the preset. Then when a new group is created it got the changes from the first preset.

Tags: