The Node Reference module defines a field type for use by the Content Creation Kit (CCK) to reference one node from another. It works very good and allows you to add a greater amount of complexity to your site. The only problem with the Node Reference module is that the default display options for the referenced node field are very limited. But thanks to the Node Reference Views module, you can use all the formatting power of the Views module to display your referenced node field.
An often used example of when to use this module is for creating a music library listing using CCK: Content types are created for the albums and the songs, then Node Reference is used to relate the songs to their respective albums. For this example we will have a content type called Album with text fields for title, year, artist and a content type called Song with a simple text title and a node refernce field to relate the song to the Album called field_album_reference. From here, I will give quick setup instructions to get you going with the Node Reference Views module:
Before you begin, you should have the following modules installed:
Content - http://drupal.org/project/cck
Node Reference - included with the Content module
Option Widget - included with the Content module
Text - included with the Content module
Views - http://drupal.org/project/views
Views UI - included with the Views module
Additionally, you should setup the above described songs and albums content types or have a set of content types connected by a node reference field.
Node Reference Views - http://drupal.org/project/nodereference_views
Once you have downloaded the module, move it to the appropriate modules folder for your install and extract it in place. From the Modules page (Administer > Site building > Modules), enable the Node Reference Views module.
From the views administration page (Administer > Site building > Views) enable the view entitled field_noderef_example after reading the brief description/instructions. Now on this newly enabled view choose clone. The most important thing to rember with this setup is to rename this cloned view to have the exact same name as your node reference field, in our eample this is field_album_reference. Fill in the view description and the view tag with something that will help you remember what this view is, and then choose next.
Modify the view by choosing 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. Do not change the arguments field. Finally, Save the view.
From the views administration page (Administer > Site building > Views) disable the previously enabled the view entitled field_noderef_example.
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 described. Nice. It can be styled like any other view can be.
Comments
Nice tutorial! May I take
Nice tutorial!
May I take parts of it to improve the documentation for the module?
-- Joachim (maintainer :)
I would feel proud to
I would feel proud to contribute to the documentation.
Thank you! I've added a
Thank you!
I've added a summary here http://drupal.org/node/481718 and linked back to this walkthrough.
BTW, I noticed on reading more closely, you don't need to run update.php when you install modules, only when you update them :)
-- Joachim
Struggled to get Node
Struggled to get Node Reference working correctly. The tips here filled out the missing links.
Thank you.
Post new comment