Search code examples
phpdrupalviewrelational

Using nodereference + views to create combined view


I'm trying to set up a relational View but not sure how to do it.

Here's an example of what I'm going for using the node types Artist and Song.

Artist               Song                    Length
Bob Dylan           Like a Rolling Stone     2:00
Bruce Springsteen   Atlantic City            4:00
Burce Springsteen   Born to Run              5:24
Van Morrison         Domino                   3:22
Van Morrison         Brown Eyed Girl          4:30

Assuming I have an Artist node type that has a node reference to Song (set to unlimited) and a Song data type with an additional field for length, how would I go about configuring the view to output this view?

Thanks! Ian


Solution

  • Here's an answer I got in the Drupal forums which worked perfectly:

    The following assumes that artist is the title field of artist, song the title field of song.

    Create a view with the following Fields: Title (label set to Artist) Filters: Node: Published set to yes, Node: Type set to Artist.

    You should now have a view that lists all artists.

    Add a relationship on the node reference field in artist for songs, make sure delta is 'all'. When adding the next two fields use the relationship Field: Node: Title (label set to Song) Field: Content: Length (or whatever you call the field)

    Now under "Basic settings" set style to 'table'.

    http://drupal.org/node/825168