Sort view by order of taxonomy terms

Hello,

  • I have a Preview List of touristic / educational offers (https://test-voisins2.web.cern.ch/offers )
  • I have a taxonomy with 3 terms: “Registrations open”, “Registrations closed” and “Freely accessible”.

I would like my offers to be displayed in my Preview List according to the following order:
1- Registrations open
2- Freely accessible
3- Registration closed

However, the “sort criteria” by taxonomy term only offers to displays the terms by alphabetical order (asc. or desc.).

How could I do to have the display I want?

Thanks in advance,

Marie

Hey Marie,

Your goal is to sort nodes based on the order of a taxonomy term that they are tagged. In order to do that follow the following steps:

In your view…

1) Create a relationship to the taxonomy field of your nodes

By default the nodes do not have access in the order of your taxonomy. In order to gain this access they need a Relationship.

a) Under Advanced > Relationships click on Add.
b) Search for the field of the content type that tags your content with the taxonomy and add it
c) Mark Require this relationship

2) Add Sorting factor for the taxonomies

Now that you have connected the content with their taxonomy, you should sort them based on their weight.
a) Under Sorting Criteria of the view, click on Add
b) Add the field called Taxonomy term: Weight
c) In the Relationship field choose the one you created in step 1

then in your taxonomies page…

3) Sort your taxonomies

a) Visit the page of your taxonomies
b) Order them in the order you mentioned.
c) Done. Visit your view and make sure they display in the correct order.

Note: If they are displayed in the reverse order, click on the Sorting factor you added and change the order from ascending to descending or the other way around.

Let me know if it works.

Konstantinos

1 Like

It works perfectly!
Thanks :slight_smile: