Reverse Node References

Here is a use case that happens to me all the time, and I am boggled that I haven’t found a simpler solution. I have a bunch of Faculty nodes, and I want to specify that some of them belong to various Committees. I want a committees page that has a linked listing of committees, and then each committees page should have a description of the committee and a linked list of all the members. Also it needs to be dead simple for a non-skilled content editor to edit the committee descriptions and to create new faculty without needing to create all the committees ahead of time.

You can do almost all of this with Taxonomy free tagging and Views 2, but the easily editable per-committee description trips you up. For that you need a node type with a Reverse Node Reference. I am open to suggestions, but here is how I do it:

  • Views 2
  • CCK’s Node Reference
  • Popups: Add and Reference

  1. Create a Committee node type.
  2. Add a Node Reference to the Faculty node type called ‘committee’.
  3. Use Views 2 to create a reverse-reference view (These instructions are based on Create a view on a node reference field)
    1. Add a view with view type ‘node.
    2. In Relationships section select the committee node reference field and enable ‘Require this relationship’.
    3. In Arguments section select ‘Node:nid’ – this will be used to enter the Artist’s node id.
      1. In Arguments Configuration, select the Relationship ‘Committee’.
  1. Use the appropriate Sort criteria. I used ‘Last Name’.
  1. Then create a node-committee.tpl.php in your theme, and add:

<?php
  $view
= views_get_view('committee_members');
  print
$view->preview('default', array($node->nid));
?>

This accomplishes all my goals. The editor can create a new committee either from the “Create Content” page, or while creating a new faculty member, and the committee description is easily edited. I am a little unhappy having to resort to the theme layer. Maybe I won’t need to once the viewfield module releases a stable Drupal 6 version.

How about...

http://drupal.org/project/viewreference ?

This has (or purports to have) similar functionality to viewfield, but has a stable release for D6.

I haven't used it as yet, but probably will be, quite soon - for similar reasons, I expect!

I tried it. It can achieve

I tried it.
It can achieve this functionality, but at the cost of requiring the content editor to paste the name of the new node into an arguments text field. There seems to be no way to automatically pass the node id as an argument.

NodeReferrer

This sounds a lot like what the NodeReferrer module did for Drupal 5. There's no D6 version of that module (yet?), but anyways I find it great that this can now be done in Views itself without any further modules :)

The super cool thing would

The super cool thing would be if the Drupal 6 version of NodeReferrer would automatically create the view for you.

D6 of Nodereferrer

http://drupal.org/node/259837#comment-1040436

Seems to be working for many people

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.