How to dynamically group content in a views listing I've hit a massive wall in trying to group a list of nodes displayed through a view on my Drupal 7 site. Currently I have a view that lists a group of nodes that are under a specific vocab term. I then use a weight field to make sure they are in the order that I would like. This works just fine.

Here is an example on my site. In this example I have 11 videos bundled together under one taxonomy term.

What I would like to do is now create "chapters" to better organize these. Using the example above I would like to be able to have the following output:

HEADING 1  &lt;-- I want to add headers like this. And then group videos in each header.
 1. Video 
 2. Video 
 3. Video 
HEADING 2
 4. Video 
 5. Video 
HEADING 3
 6. Video 
 7. Video
 8. Video
 9. Video
 10. Video
 11. Video 


The big caveat is that I want to be able to assign these "chapter headings" at different spots for each video series that I have. I don't want to have Chapter 1,2,3 in the same position every time.  

Here is an example of how I would like to be able to group my individual videos. Take a look at the video list on the left. 

One route that I tried was to create a new Vocabulary called "Video Headers" and then create terms for each header that I wanted. I then created a new term reference field in my video content type where I would choose the corresponding "header" term that I wanted. But I am having trouble grouping this in my view. It's just not grouping correctly.

I've looked into the Book Module, but that doesn't seem like the right fit. My gut tells me that it has to come down to using taxonomy terms to group these videos.

UPDATE: Thanks to Jason below I was able to almost get it working. The problem is that all of my videos show up in the view rather then just the videos that are under a term. In order for my lists to work I have to have a contextual filter:

UPDATE #2: Figured it out! With help from Jason below, I also added a contextual filter of "Has Taxonomy: Term ID". That showed only the nodes associated with a term. 



So as soon as I add that contextual filter, it ruins my grouping and groups all of the videos that I have together with one header. Somehow that is breaking it.
Try this out.

Add the taxonomy term (or entity) reference field to your output, exclude it from rendering, and configure the format settings to group on this field.

Add a relationship to you view based on the term (or entity) reference field you are using to reference the taxonomy terms. With this relationship, you can now add a sort field using the taxonomy term's weight. When you click to add a sort field, filter the options to taxonomy term using the drop-down select to the right of the search field in the add sort dialog. Once filtered, you will now see the taxonomy term weight.

Adding this to your sort, will allow you to sort the view results based on the node's referenced taxonomy term's weight within the taxonomy vocabulary. You could also sort on the term itself, if your term names will include numbers like, "1. Chapter 1" and "2. Chapter 2", etc.

Jason.