3

I am using views to group a list of nodes by taxonomy term and display these groups as accordion headers (displayed by the views accordion module).

eg:

Yellow:

  • node1
  • node2

Green:

  • node1
  • node3
  • node4

Mauve:

  • ..

I have the nodes sorted by node:title (asc), but with or without the title sort, putting in a sort in for term:title does not seem to order the accordion headers as I had hoped. This might normally be a small niggle, but in this instance the end users are librarians...

I suppose I could go down the custom module route and devise my own block to display the terms/nodes without going through views. I would very much prefer not to do this, as it will be another maintenance demand for a quite complicated site.

The best I have found in looking for a solution is this discussion, but no solution is proposed, and I just have a nagging feeling that there must be a way to do this.

I would be really grateful for any suggestions.

5

How I resolved this

I don't know what I did wrong in the first place here, as after having removed sorts from my view and added them again the ordering is fine, and not complicated at all

Summary

If you are contructing a view of nodes, grouped by taxonomy term, and using the grouped field (term:title) as views accordion headers, then you can easily sort the accordion headers by taxonomy title/weight, and their child items by node title. To do this add a first sort criteria for term:title/weight(asc), and a second sort criteria for Content:title(asc).

I opted for a sort based on weight in the end, as I can always reset vocabulary weights to alphabetical order, and this allows the editors a bit of free choice if they need to prioritise the list.

3

I solved mine similarly to autopoietic, except I needed to add the Relationship to the term reference field in order to get the weight to show up in the Sort section.

2

It's important to note that to make this work, you have to create a relationship in the view. The relationship should refer to the taxonomy vocabulary. Otherwise, you won't get the term weight as an option in the sort criteria. Add relationship

Then, once you have added the relationship, create the sort option and be sure to choose the relationship you just created.

Link sort criteria to relationship

  • I did such a view. It replaces the search page and allows to search for nodes. They appear grouped by type. I had the type creteria without needing a relationship. – Mars Sep 17 '18 at 12:04
1

I would like to share my personal experience with this grouping and sorting 'thing' from within Views. In this short 3 minutes demo video i am illustrating the scenario in my Ubercart Products catalog view, which is filtered both on regular as contextual (via URL) expressions : http://castabo.rawdesk.be/temp/Views-grouping-taxonomy-tags.flv As you can witness this setup works for me as long as no pagination occurs in the eventual result set. Once pagination occurs, the grouping is apparently performed on each page separately. EG. my Cardiology panel taxonomy tag group is spread among 3 pages.

Important note : this recorded scenario does not contain the additional Views Advanced Relationship addition as suggested in this similar case study : http://www.wdtutorials.com/2013/08/14/drupal-8-tutorial-how-order-view-groups-taxonomy-terms-also-drupal-7#.VB1sHBaOp8G I also tried with this additional relationship, but the result was exactly the same as recorded in my video.

So it is in my opinion not 100% waterproof unless someone else proofs here otherwise (ps. avoiding a question..)

0

You should be able to add the term id as a field. Exclude the field from the view and group based on that. Then however you arrange the terms in the backend should show in the view. The sort you add to the view will affect the child elements.

If the titles show the term id instead of the title just rewrite the output of the field to include the title.

  • thanks jsheffers, I will try that, though are you certain that this approach does not rely on term:weight rather than term:nid? – autopoietic Dec 18 '13 at 17:47
  • thanks again, I added my own answer because my solution did not require adding a field or involving the term id. – autopoietic Dec 19 '13 at 10:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.