Drupal 7 Views - list group by field

☆樱花仙子☆ 提交于 2019-12-03 21:13:38

问题


I have a View that list content of type Bio (the biographies of people). However, I would like to format it so that they are grouped under different headings.

I added a new field to the Bios content type which is a dropdown list with three different options - Foo, Bar and Baz. What I want to do is display the people under the heading of their respective group.

Currently:

- John Doe
- Jane Doe
- Jack Doe
- Juanita Doe
- Jim Doe

What I want:

#Foo
- John Doe
- Jane Doe

#Bar
- Jack Doe
- Juanita Doe

#Baz
- Jim Doe

回答1:


You should be able to do the grouping simply within views. No need to touch the template.

Here's how to group:

  1. Add the field that's the drop down to your list of fields in your view. If you don't want to display it with each person though (just want to display it at the top), make sure you select 'Exclude from display' when you're setting up the field
  2. Click to configure the settings of your view's format. I'm using 'Unformatted list' in my example, but this could be an html list or a table...

  1. Select the field that you now have in your view (even though you're not showing it) as your grouping field!

That should be it! Let us know if it works for you.



来源:https://stackoverflow.com/questions/13828952/drupal-7-views-list-group-by-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!