开发者

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:

  • Album ABC

    • Track 1
    • Track 2
    • Track 3
  • Album DEF

    and so on.

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

Thanks.


  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


Try Field Group or Display Suite.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜