The Node reference views module is a formatter for the CCK nodereference field. The default displays for node reference fields are just node titles, full nodes, or teaser. This module allows you to use the formatting power of Views module to display the node reference field: this means you can pick any fields on the referenced nodes, show them as a list, table, or grid, all in the place of the original node reference field.

Usage

Install the module as usual.

Go to the views admin and create your view. The view should have the same name as the field, including the automatic 'field_' prefix, eg 'field_my_noderef'.

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.

Go to the display settings for your field, and pick 'View' as the display option for your field.

Example & walkthrough

Suppose you want to make a music library with node types for albums and songs.

The song nodes have a node reference that points to the album the song is on. Album nodes have fields for artist and year.

Default CCK nodereference will display the album field on song nodes as just the title, or teaser, or a full node. Instead, you can output whatever fields from the album node you like.

  1. From the views administration page (Administer > Site building > Views) enable the view entitled field_noderef_example after reading the brief description/instructions.
  2. On this newly enabled view choose clone. The most important thing to remember with this setup is to rename this cloned view to have the exact same name as your node reference field, in our example this is field_album_reference.
  3. Choose additional fields from the referenced node to be displayed as well as modifying most of the rest of the view settings to suit your needs. Save the view.
  4. Optional: You can now disable the preinstalled view, though it's not essential: from the views administration page (Administer > Site building > Views) disable the previously enabled the view entitled field_noderef_example.
  5. Edit your content type (Administer > Content management > Content types) that contains your node reference field. From the tabs choose Display Fields. Choose view from pulldown on your node reference field, in our example it would be the Album field.

Now when you view your song nodes, the Album field will appear as the view you previously set up. This can be altered further, and themed as any normal view. You may modify it in any way you like, apart from the Node nid argument field and the view name, both of which are needed for the field display to work.

(The above is an abridged version of a walkthrough by timb.)

Reference

The default view has the following arguments:

- Node: Nid: this gets passed all the nids that are the values of your nodereference field. This argument is what causes the view to show the right nodes.
- Global: Null: this gets passed the nid of the current node, ie the one on which this view is displayed. This is not used by this module, but may be useful for theming, or for more complex views.

Troubleshooting

Before filing a support request, please check the following:

- Clear your cache if the view option doesn't appear in the CCK display options.
- This module is a formatter. It doesn't do anything to the widget on the node edit form, or affect it in any way.
- This module doesn't let you pick a view for each node. It uses one view for your field, on every node. Look at modules such as Viewfield, View Reference for this.
- The view is selected automatically by its name. The 'advanced view' section in the field settings uses a view to make the list of nodes you pick in the widget, which is a different thing entirely.