Drupal Views term sorting criteria
Views is great. Views is also confusing.
When sorting by Taxonomy Terms, programming can be challenging but it is not that difficult once we understand the concept.
Taxonomy Terms are sorted by term ID. This means that if you add a new term at a later date it will be displayed at the bottom of the column list instead of being alphabetically displayed. this can give you a huge headache until you figure out what is going on (it is being sorted by term_id).
To sort alphabetically by Term Name, we need to create a Relationship that links the Term_id to the Term_name itself.
- Add a relationship selecting "Taxonomy: Terms on node". After you click add, it will show you all the taxonomy classes available. Select the one that applies (the Term Name you want to use). This will link the term_id to the Name Assigned To The Term ( linking two different content types)
- In the sort criteria, select "Taxonomy term: Name" . Do not duplicate: if you had previously sorted by Taxonomy Term and it wasn't working make sure you delete the old criteria.
There are more issues to consider. For example, if you sort by Taxonomy Term and also by the Content Title as a second sorting value, you may (also) need to do the following:
- On the FORMAT Settings choose to sort by Taxonomy Term but select the Content Title as your default sorting. Save.
- Go back to the sorting "Taxonomy term: Name" and make it EXPOSED to user otherwise Views will get confused and it will by title only (the one set as default sort).
Click on "read more" for a pictorial diagram...