The Drupal Steward web application firewall helps bridge the security gap to provide protection for your website.
So I feel like I must be missing something obvious, but I can't find a solution to my situation. I'm trying to sort some nodes by the chosen taxonomy term name. This is Drupal 7, Views 3.
I have a taxonomy vocabulary 'Country' that is setup something like:
Asia
--Bangladesh
--India
--Vietnam
Afria
--Algeria
--Libya
--Nigeria
On the content type ('Partners') I have a taxonomy field called field_country. I happen to be using the Hierarchical Select module to make sure that, for this field, only the deepest levels are chosen (countries, not regions).
So all of that works and I can display the country chosen as a field in the view.
But I can't seem to figure out the correct way to sort by that country name. When I add the field_country field to the sort criteria, the ordering doesn't make sense.
Any suggestions? Is there a magical relationship I have to activate to get the correct sort option available?











Comments
Doh!
Never mind. I feel like an idiot today. I've done this before, but just seemed to have a brain issue.
Very simple:
1. Add a relationship with "Taxonomy: Terms on node". Select the country vocabulary.
2. In the sort criteria, select "Taxonomy term: Name" (I believe this gets added by step 1) and make sure the relationship you create is selected.
http://system-werks.com
Thanks from the future...
Thanks for taking the time to reply to your own issue with the solution you found. It saved us a ton of frustration. Your issue was a top Google result for our query as we were having the same problem. Since you put in a solution, we did not have to keep digging. So, Thanks!
thanks
Thanks again for posting the solution. All to often people respond with, "nevermind I solved it". This saved me much time.
Thanks for the side note in step 2
The was simply the piece that slipped my mind, thanks for mentioning it!
I also thank you!
I also thank you!
Show the terms
Additionally, if you want to show the rendered taxonomy terms, as a visual way of sorting and linking to those, here's how I did that:
Brian
2017 and STILL Saving My Bacon!
Was trying to hack this together and FINALLY found this. Thanks!
And if it still not changing
And if it still not changing the order to be right remember to clear cache!
thanks!
Even 4 years later your response to your own question has saved me a ton of head banging. Thanks!!
And it's still helpful~
This is a great thread - thanks!
Tom Hale
New Day Web Design
www.newdaywebdesign.com
sort taxonomy
Old thread but thanks! works for me (Drupal8)
Thank you
Thanks - done this several times before but still catches me out. Your post formed a great reminder.
Very quick and
Very quick and simple.
Fantastic. Thank you.
Thanks a lot!
Thank you for your solution!
Thanks~
Once again, the simple solution can be hard to figure out. Thanks for sharing your own solution.
Tom Hale
New Day Web Design
www.newdaywebdesign.com
Thanks!
Another happy community member! (worked for me).
I just want to say that if
I just want to say that if you're trying to sort by term name with a Search API index view in Drupal 7, the process is:
Hey Thanks for posting this
Hey Thanks for posting this solution. Was a big help!
For those doing the same in Drupal 8 the steps are the same, however the language in View has changed slightly.
Original instructions with minor D8 changes
Very simple:
1. Add a relationship with "Taxonomy: Terms on node". Select the country vocabulary.
2. In the sort criteria, Add sort criteria, choose "Category Taxonomy term" then select "Name" under Taxonomy term and make sure the relationship you create is selected.