views:

147

answers:

3

My site is to have a section for normal users, a section for managers, and a section for use only by anonymous visitors. Each section of the site requires changes to Drupal settings for using a different theme, changing the Primary & Secondary links, changes which blocks are used, etc. In other words, the user experience changes significantly from section to section.

I could probably accomplish what I need by using Drupal's multi-sites, a shared database, and using settings.php to override the variables I need to (ie: menu_primary_links_source). However, to make things more manageable from an operational point of view, and to buy flexibility, I'm considering using the PURL API (purl.module) to prefix the URLs for certain site sections, and having my theme and custom modules react according to the current PURL prefix.

Before I get started, I want to ensure I'm not discounting Spaces.module. Spaces uses PURL, Features, and Context (which I'm also currently using for my site). I don't entirely understand how exactly Spaces fits into the picture. Would it help me make different site sections, each with specific configuration & behavior? Or am I better off depending directly on the PURL API?

A: 

I would suggest using Spaces or Organic Groups. Spaces was used considerably in Open Atrium... a Development Seed out-of-the-box intranet package. Intranets really require the concept of access control and feature visibility depending on which department or role you have so I'm confident that Spaces will be very good for you.

Of course there is the venerable Organic Groups also. Spaces is a "higher" level concept than PURL. Spaces uses the context and PURL modules BTW. My gut instinct is for you to use Spaces or Organic groups.

There are a couple of videos on the net that talk about Spaces. Check them out.

Sid NoParrots
I just watched the Spaces 3 demo video. It's an excellent tutorial, and I do see how Spaces will help me with my project: http://vimeo.com/8241142Still don't understand how I can use PURL with this though. I want to be able to have a URL prefix applied while in a Context - ie: while in the "Manager" section of the site, every url is prefixed with "manager" (eg: manager/node/add, manager/search, manager/node/34).
rcourtna
+1  A: 

The way I understand the spaces module is this:

It provides a way for the features module (and your "features" created from this) to integrate with and be available within defined areas of your site. Out of the box this includes: Organic Groups, Taxonomy, and Users. There is an API to define more "spaces" than this.

So for example you could create a "feature" (with the features module) of an image gallery. Using spaces with organic groups, you would be able to have each group have the ability to enable and disable this feature and it would only be available within that "space" (group in this case).

From the organic groups page:

Groups get their own theme, language, taxonomy, and so on. Integrates well and depends upon Views module

So in your situation, you could think of spaces as a way to make organic groups more flexible. As NoParrots said, OpenAtrium (http://openatrium.com/) relies on the features/spaces/context modules heavily, so that might be a good place to review how these modules work together.

EDIT:

I found a great video that might explain things more clearly: http://www.archive.org/details/TheHeartOfOpenAtriumContextPurlAndSpaces_782. Around 16:00 he starts talking about PURL.

From this page (below the video) there is also an explaination of PURL/Context/Spaces which I think is pretty good:

  • Context is a module for triggering reactive behaviors within a page load. Controlling block visibility, menu trails, page classes, and page template layouts are examples of things that fall into its jurisdiction.
  • PURL is a library for capturing and abstracting request handling that goes beyond what the Drupal core menu system provides ($_GET['q']). Detection of request components, like subdomain, path prefix, user agent, or file extension, and sustaining their presence is its primary role.
  • Spaces is a generalized configuration override framework. In theory it allows you to "customize everything, for anything." In practice it allows things like custom group colors and features, per-user dashboards, and multisite-like usage of a single Drupal install.
bkildow
Thanks for the answer. I can see clearly how Spaces will make it easy to create a customized user experience on a per-space basis. What I don't understand is how PURL comes into the equation. If I want to implement Persistent URL prefixes for each Space, do I still need to write to the PURL API, or does spaces somehow help here?
rcourtna
I'm not 100% sure, but I think there may be integration with PURL and organic groups to define a path perfix for each group. See my edit above for a video that may explain things better than I can.
bkildow
That video is excellent. I think it answers all of my questions. Thanks!
rcourtna
+1  A: 

The Spaces-PURL-Context conundrum. Fun. I've been meaning to write this up long-style to finish wrapping my head around it.

What is Spaces?

Spaces is a module that creates containers of overridden configuration for your site. It's not specifically about features, it's about any number of configuration values that are able to work with Spaces, including whether a Feature is active or not. (Active does not mean the module is disabled, just that a number of Feature-oriented things are whisked away, such as content types and Spaces-aware Views.

When using Spaces, you need to decide what type of "buckets" you want to use. Open Atrium uses OG and User-shaped buckets, what you need is a new sort of bucket based on user role. For the sake of sanity, you might even need to create a separate module just to define user roles as a more concrete thing in Drupal, kind of like how Spaces OG needs to lean on Organic Groups for a number of concepts.

What is Context?

Context is ultimately a page decorating mechanism. You tell it some stuff about the page, it modifies the page accordingly. Context cannot modify the URL, it's the other way around. Features define Contexts to tell the site how to render a given page uniquely for that Feature, there is no direct connection between Context and Spaces or Context and PURL.

What is PURL?

PURL is a method of sticking things in the URL and keeping them there until you are done with them.

How this Glues Together

Spaces with PURL integration are triggered based on one of two things: The URL or something about the content in the page. To explain this, I'll use Spaces OG as an example.

  1. You click a link. The link was prebuilt with a PURL component that Spaces OG is watching for clues. If that piece of the URL makes sense to spaces, the Space is triggered.
  2. All links except those that opt-out of the PURL modification persist the PURL URL element, meaning the Space is happy, and re-triggers with each page load.
  3. Spaces OG knows to check nodes for their group affiliations. If Spaces can crack open a node and find a group, it will trigger that node's Space, using PURL's modified version of drupal_goto() to redirect the whole page for URL consistency. This will trump any existing URL structure.
  4. If there is no URL component, and the node has no group affiliation, no Space is triggered.

Once the Space is triggered, all of that Spaces configuration values are pulled into play. This will mean the Space's preset defaults (you can have multiple default Space configurations for every Space type) overlay Drupal's defaults, which in turn are overridden by any configuration saved specifically for the Space. In the case of Open Atrium, this includes such nice things as group color, blocks on the dashboard, and enabled Features.

If the user goes to visit something provided by a Feature--a Node, a View, etc, any Contexts related to that node, that view, that URL that any module provides might just be triggered, and start doing things with blocks and theming to tailor the page for the Feature's content.

Next Steps

As I mention above, it sounds to me as though your first step is to try looking at Spaces OG, and rewriting it to be centered around the User Role instead of Organic Groups. You shouldn't have to do much with PURL directly besides a little copy and paste from Spaces OG. You might want to post in the Spaces issue queue to float this idea where the maintainers might see it and give pointers.

Grayside
This is a really informative answer, thank you for explaining how it glues together. For my scenario, I do believe that I'll follow your advice and use spaces_og for guidance. If I understand it correctly, my module will firstly create a PURL provider, and secondly a new type of space that will become activated based on my PURL prefix.
rcourtna

related questions