ramya
ramya

Reputation:

Drupal 7: Displaying nodes by grouping them based on a field

Is there a way to group nodes based on a node reference field and display them in a list. Say, I have a content type Album, and nodes Album ABC and Album DEF of type Album. These are referenced in nodes of content type Track. How can I display all the albums with the referenced Tracks in which they are referenced as a list?

For example:

I have been using Drupal only for a few weeks now, Can anyone explain the answer given below??

Thanks.

Upvotes: 2

Views: 1777

Answers (2)

Khaled Al Hourani
Khaled Al Hourani

Reputation: 3327

Try Field Group or Display Suite.

Upvotes: 0

David Fells
David Fells

Reputation: 6798

  1. Create a view filtering on the node type = album
  2. Set the view output style to "HTML List"
  3. Include the node reference field as a link to node in your field list
  4. Click "theme information" then look at the name of the file that applies to the node reference field. Create a .tpl.php file with a candidate name that's specific enough for your needs will be something like views-view--viewname--fieldname.tpl.php. Click the link for the template file in use in theme information for this field, and views will show you the code in that file. Copy & paste that code to your new file
  5. In the new file, you'll want to write a little PHP to output your links as a list. If you enable the devel module, put in the page, and inspect what's available. One of them will be an array of links. Output that with

Upvotes: 2

Related Questions