Node Reference Views example

This module is now deprecated. Development continues at Reference views, which is essentially the 2.x branch but with a new name.

This module provides a new display formatter for CCK node reference fields. The formatter allows a view to be used as the display style for CCK node reference fields. This means that instead of just a title, teaser, or full node, you can show nodes using any fields that are available to Views, in any sort order, in any view style, with any views theming.

The view should have the same name as the field, including the automatic 'field_' prefix, eg 'field_my_noderef'. The first view argument must be a node id, set to allow multiple ids: this has passed to it all the nids from the CCK nodereference field. No other arguments are passed to the view. The view's default display is shown.

To get started, you can clone the example view that comes with this module: it comes with the argument already set. You can add any fields and sorts and filters. One limitation however is that the order of items set in the CCK field isn't accessible to Views.

This module does nothing to node edit forms.

Other modules

This module is fundamentally different from modules such as Viewfield, View Reference. These give you a field where you pick a different view for each node. Contrast with this module, where the same view is shown on all nodes: what differs is the list of nodes within the view, which are those you picked in the CCK node reference field.

Example

Suppose you want to show selected forum posts on project nodes. You'd add a CCK nodereference field on the project type, and for each project, pick some nodes. So on each project page, you get some forum posts listed. Your options for how to show these on project nodes are: titles, full nodes, or teasers.

But perhaps you'd like something else on your project nodes, such as a table of forum posts that shows post title, post author, and comment count. This module lets you do that.

First, clone the example view, give the new view the same name as your CCK nodereference field on the project type. Add the fields you want (fields on the forum nodes now). You can add a sort order too. You probably don't want any filters: the argument that is set in the example view is what gets you the nodes that are selected in the CCK nodereference field. Set the style to whatever you like: table, list, etc. You can use any views theming you like too.

Now set the display option on the CCK nodereference field to 'View'. This will pick up the view you've created, and display your table of forum posts on your project page.

Project Information

Downloads