Adding photos to an event page with Views Attach

Published August 27, 2009

There are often 17 ways to do any particular action with Drupal - here is #18 on the list of "How do I display related content on this node's page?" You'll be using the Views Attach module and a nodereference field.

In this example, you want to relate a photo to an event. Inside the photo's content type, create a nodereference field that is able to reference the event content type. When a user is adding a new photo, she will be able to choose the related event if applicable.

The goal now is to have related photos appear somewhere on the event page. You can always use blocks, but Views Attach allows you to place the view amongst your CCK fields with the same drag-and-drop you would use to move the Title or Body field around.

To create the view, go read our article about nodereference or our other article about nodereference.

Once the view accepts the event's node ID as an argument and properly displays the related photos, you need to create a new Display in your view of the type "Node content". This is a special Display type provided by Views attach for placing inside of nodes. There will be an option to choose which node types the view should be attached to - in this case, you should choose your event type.

That's it! End Quicktip. If you'd like a more visual example, you should certainly watch eaton's Photo Gallery video on

Sign up to receive email notifications of whenever we publish a new blog post or quicktip!