By big_smile


2011-06-15 18:31:48 8 Comments

How do you group a list of nodes by the taxonomy term?

e.g.

Term 1 
--- Node 1
--- Node 3
--- Node 7

Term 2
--- Node 6
--- Node 9
--- Node 12

I have tried creating a view with "Node" and "Taxonomy Term" as fields. I then enabled grouping, and grouped by the taxonomy term. Doing this outputs the following:

Term 1 
--- Node 1
Term 1
--- Node 3
Term 1 
--- Node 7   
Term 2
--- Node 6
Term 2
--- Node 9
Term 2
--- Node 12

There is a Drupal 6 tutorial here that explains how to fix it, but it doesn't work under Drupal 7.

It seems like such a simple task, yet after many days of trying, I can't get it to work! I've found many threads of people asking the question, but no solutions (at lease a solution which doesn't involve installing taxonews).

2 comments

@Selyne 2012-03-09 10:23:58

I resolved the problem of duplicated grouping fields :D

So, for people who have the same problem, just disable your module Themer and it's done !

Hope it helps.

@Shoaib Nawaz 2011-06-15 18:59:57

In your view add two fields: - Node title - Taxonomy Term

You are right up to here.

Now:

  • Set the "Taxonomy Term" field to "Exclude from display"
  • Select your views' format as unformatted list; use "Edit settings" for the format
  • Set "Grouping Field" as "Taxonomy Term"

For details, view my views' export data in pastebin.

@big_smile 2011-06-15 19:30:26

Thanks for your reply! I have followed your instructions and pasted in your views export data. But I still get it like the second example (where there term field is repeated for each node and not just displayed once [for the group of nodes that belong to that term]). Any help would be great as this is driving me crazy!

@Shoaib Nawaz 2011-06-15 19:47:23

The repeated Term is due to field selection, You need to open your Term field in edit mode and check the option box against Exclude from display. This will hide the term from view.

@big_smile 2011-06-15 20:31:25

But if I hide the term, then the list of nodes doesn't have a heading, so you cannot tell which nodes belong to which term. Isn't there a way to make the term appear just once (like in the first example I posted in my opening post (in the grey box)).

@Shoaib Nawaz 2011-06-15 21:05:11

After hiding the Term, you need to focus on Views' Format. Click on Settings against Format. Then Set the Grouping Field as Taxonomy Term

@big_smile 2011-06-15 21:17:37

Thanks for your help. I have tried what you have suggested, but the results still appear with the taxonomy term repeated for each field. I also tried your paste bin code, but same results. Here is my view exported to paste bin: pastebin.com/KNdGYyA8 I don't know if it will help with the solution.

@big_smile 2011-06-25 18:15:39

I'm not sure what happened, but it's working now! Here is the exported view, just in case it helps anyone: pastebin.com/nYn4R97a

@Kevin Morse 2012-04-16 07:57:23

ANy way to add a class or change the element type of the "Grouping field". I have this working exactly as mentioned but can't seem to make my grouping field anything other than an h3

Related Questions

Sponsored Content

1 Answered Questions

Taxonomy-term based block display

1 Answered Questions

[SOLVED] Is there a downside of having too many features?

  • 2018-11-20 11:46:42
  • donquixote
  • 60 View
  • 1 Score
  • 1 Answer
  • Tags:   7 features

2 Answered Questions

[SOLVED] Display all nodes with identical field value to current node

3 Answered Questions

[SOLVED] Other (related) nodes with the same taxonomy block grouping problem

  • 2014-12-02 22:51:41
  • herci
  • 2173 View
  • 3 Score
  • 3 Answer
  • Tags:   views

2 Answered Questions

[SOLVED] How to remove core taxonomy rss feeds

1 Answered Questions

Live filtering of nodes by taxonomy terms?

1 Answered Questions

[SOLVED] How to get taxonomy synonyms working robustly with Search API?

  • 2012-09-09 16:59:27
  • user56reinstatemonica8
  • 3624 View
  • 20 Score
  • 1 Answer
  • Tags:   7 taxonomy-terms search

2 Answered Questions

[SOLVED] Join or create group on registration

Sponsored Content