Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Drupal 7 Views - list group by field

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
like image 663
user1810125 Avatar asked Dec 26 '22 13:12

user1810125


1 Answers

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...

enter image description here

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

enter image description here

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

like image 139
Boriana Ditcheva Avatar answered Dec 31 '22 15:12

Boriana Ditcheva