We’ve spent a lot of time as a team building similar and sometimes identical Drupal features for different projects. When you think about the Drupal community as a whole, you can just imagine the number of times someone has taken these steps to build a simple Drupal blog:
Recipe for a Drupal blog
-
create and configure the “blog” content type
-
add some useful CCK fields: subtitle, image, emfield, etc.
-
create a freetagging vocabulary for your blog content type
-
create a blog listing view and an archive/tag driven view
-
create a recent comments/most popular sidebar block and turn it on
This takes someone who knows what they’re doing maybe an hour or two. It might take someone new to Drupal much longer. Wouldn’t it be nice if we could package all this up and turn it on with a click?
The Definition Approach
We package features like this by giving them formal definitions. Another way to do this is to translate the steps above into a script and drop it in a module’s .install file, but we’ve found that the definition approach allows us to easily reuse features against different facets of a Drupal site — what we call “Spaces”:http://drupal.org/project/spaces.
!http://farm4.static.flickr.com/3339/3234280469_b156b7abc5_o.png!
A space is just a certain slice or facet of your site — for example, all posts that belong to an organic group or all posts by a certain user. When you have a formal definition of what constitutes a feature, you can use that definition to attach that feature to any number of spaces on your site (i.e. Eric’s user space or the Development Seed team’s group space).
!http://farm4.static.flickr.com/3414/3234280495_30474f133c_o.png!
We based our group intranet off of this concept. And since each group and user could enable/disable and customize each feature to her liking, we needed a few tools in Spaces to provide functionality beyond what a typical Drupal module provides:
-
a way for a feature to be enabled/disable per space that wasn’t simply turning off the feature module
-
a way to store configuration for a feature per space so that Eric’s configurations were distinct from the DS Team’s configurations
!http://farm4.static.flickr.com/3434/3234280391_509af28638_o.png!
A Paradigm for Reusable Features
Features can be turned on and off for any slice of your Drupal site for which a space can be written. There are spaces modules that integrate against organic groups, users, and taxonomy terms. Now there is also a fourth integrating module that treats your entire site as its own slice — spaces_site.
Spaces site is admittedly a mindless module — where other space types need filtering and routing logic, spaces site has practically no rules. Its main job is to put a feature plug onto your Drupal site. The implications are enormous. Once built, a single spaces feature can be used, enabled and customized on group spaces, user spaces, term spaces, or your entire Drupal site interchangeably.
Spaces, Spaces Everywhere
Once we had our features built, we went to town. Spaces is powering our intranet group and user spaces, the features on several of our client sites, and the features on developmentseed.org itself.
!http://farm4.static.flickr.com/3107/3234280431_a513c5df3c.jpg?v=0!
Later this week we’ll show you how to create a Spaces feature step by step from start to finish and how to turn it on on your site.
What we're doing.
Latest