Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Drupal as a Metadata Framework

Parent Feed: 

My latest Drupal project is a collaboration with John VanDyk, author of the Metadata Plugin for Manila. John also wrote a great walkthrough of Drupal's life-cycle that's worth reading, especially if you've never stepped through Drupal before. I've known and worked with John for many years, and this project is something we've wanted to build for quite a long time. It's a metadata-centric approach to content management.

Most content management systems use metadata only at the presentation level, lumping it in the same category as 'user navigational aids', such as breadcrumb trails. We feel metadata can easily drive both content AND functionality given a solid framework of schemas, metatypes and actions. In otherwards, metadata becomes a collection of tools used to shape the presentation and behavior of your site. Drupal has a foot forward in this arena with the taxonomy module. Our goal is to extend taxonomy module in three areas:

  1. Open vocabularies. User's should be allowed to add terms if they have permission to do so.
  2. The ability to render terms as any HTML form field, instead of select boxes only.
  3. If a vocabulary is storing numeric information, it should be stored in the database as a numeric type. The same holds true for string terms.

On a larger scale, we're also creating the ability to add metadata schemas to existing node types. We're not declaring new node types, but extending them with user-defined attributes (aka vocabularies). Say for example you want weblog entries with 'word of the day' and 'song of the day' features, here's how you'd do it:

  1. Add a new metatype (aka vocabulary) called 'word of the day'. Choose the string data type and specify that it should be displayed as a textfield. Optionally assign actions to the metatypes, such as validators and display properties. Do the same for 'song of the day'
  2. Create a new schema that extends the original blog node type. Name it and add your two metatypes.
  3. All schemas you create are visible on the 'create content' page. Click on your new blog schema and you'll notice the 'word of the day' and 'song of the day' form fields are present. Your blog entry is the same as any other blog entry except you've extended the definition of what it means to be a blog. The behavior of this metadata is much like the current behavior of taxonomy views, allowing you to list all content with like terms.

And there's no reason why you can't have multiple blog schemas as well! Now that makes life interesting, doesn't it? Imagine a corporate intranet where each department wants to use blogs to track different types of information. Schemas would make this approach much easier than manually writing different blog modules for each department.

Hold on, there's more. Once a metatype is created, it can be attached to any number of schemas. For example a keywords metatype will probably have the same function for most schemas. It is even possible to have hierarchial metadata values since we're building on top of Drupal's taxonomy system.

So far I have been very surprised how little the Drupal core code has been modified for this project. At this stage I can't offer any timeline on when we'll be finished, but if you're coming to OSCON, look us up and we'll be glad to show you a demo :-)

Author: 
RSS Tags: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web