2 min read

Status of Nodereferences in Drupal 7

Status of Nodereferences in Drupal 7

Before my time at CP, our site was going to get re-themed and the team looked to upgrade the site to Drupal 7, which was still in development at the time, but ultimately left it in Drupal 6. One of the major reasons for not upgrading was lack of support for Nodereference in Drupal 7.

Now that Drupal 7 has a stable release, we're all reinvigorated about the prospect of building new projects in it, but we're a bit apprehensive too. Where does our old D7 nemesis, Nodereference, lie? Can we mark it off the list of prerequisites for full fledged D7 development? Well, as of this writing, not yet. But it's close.

The D7 port of Nodereference/User Reference that is endorsed by the CCK project page is http://drupal.org/project/references, although there are others looking to leverage the new "entity" abstraction layer in Drupal 7, which are currently in various states of development.

So how far off is Nodereference for Drupal 7? I wanted to know, so in my Drupal 7 sandbox I downloaded the References module (using the cool new module download GUI) and made an attempt to find out.

I decided on a simple test relationship: Bands and Albums. So I created two content types of the same names. On the Album content type I added a Node Reference (Reference?) to the Band content type. Once I did, I noticed something was missing on the widget configuration page - Advanced options to use a View to select nodes. It's a neat feature in Nodeference for D6 that allows you to limit what nodes appear in the autocomplete on the "node add" page. Not really a huge issue, since most of the projects I've worked on that used Noderef didn't use it. OK, so far so good then. I can live without that.

Nodereferance Screenshot

With my node types set up, I added some test content. A few Band nodes and a few Album nodes that point to the right band. One band, many Albums. Cool. Things worked as expected and the Album nodes showed links to the appropriate band, just like in D6.

Now comes the real test... Views. I wanted to create a test View that displays Albums, grouped by Band. First I created a new View (the new Views module for 7 is awesome by the way) with a filter on node type Album. Then I added a relationship on the Nodereference Field "band". Next I added two Node Title fields to the display. One would be for the Band, and one for its Albums. The first one got the relationship of "Band" and the other didn't get a relationship at all, so it would show the Album title. After adding a grouping on Band in the 'Style Settings' and excluding the Band node title from display, I got what I was after! A list of bands, with a list of their albums below each band name. Awesome! Looks like Nodereference is ready to go for D7! Not so fast...

Nodereference Screenshot 2
Nodereference Screenshot 3

There is one gotcha, that I'm sure will be resolved very soon, but it's worth mentioning. Currently any field added using the new Field API does not work with Relationships in Views. See http://drupal.org/node/1038240 for updates on the issue. This means that although Node data is accessible and can be displayed via a Relationship, Fields are not. Since node bodies are now Fields, this means that even the simple node body is not available to be displayed in a View with a relationship/reference.

The bottom line? Nodereference (References) is very, very close to being ready for Drupal 7 but we need to be patient and wait for a resolution on http://drupal.org/node/1038240 (or pitch in to help) before I'd try to use it in a D7 project. None the less, kudos to the developers of References: yched and fgm! The project is still young and I'm sure the issues mentioned here will be resolved soon. Thanks for all your hard work guys! If you have time and want to contribute to the project, 'All hands welcome!'


Related Posts

1 min read

Lifetime Digital - Great Case Study on Drupal Scalability

There is a great case study available on Acquia.com that details the development decisions that were made for the family of Lifetime Network sites, all of which were built in Drupal. If you're...
1 min read

Ben Bassi Appears on New Hampshire Public Radio

"Talent exists in New Hampshire, but the challenge lies in finding it", Ben Bassi told Laura Knoy and her guests on "The Exchange" Thursday.
1 min read

Drupal DIY Tip: Exporting ImageCache Presets

For most Drupal configurations, it is advisable to use exporting functionality. In addition to facilitating version control and code duplication, this method offers more direct control over the...
2 min read

How to Maintain a Technological Balance

For a very long time, CommonPlaces has been nationally recognized as one of the best Drupal design agencies in the country. We are very proud of this distinction, and we fully recognize that Drupal...