0

I have a views showing some selected terms of a vocabulary. The Views block is created using Taxonomy Terms as content(show). It showing order by the terms tree. But my client want to sort it as their business policy(most popular on top).

Is there any way to sort the terms like custom way as node queue. Please suggest me any module, hooks or other custom solutions. Here is my views settings : enter image description here

Thanks in advance.

Note that I want to sort the terms Not the entities tagging with it. I have installed nodequeue and smartqueue but unable to achieve the requirment.

3 Answers 3

0

Yes, you can add a sort option for Taxonomy term (weight), then they can reorder the terms on the taxonomy's overview page, e.g. /admin/structure/taxonomy/manage/VOCABULARY_ID/overview), or, if that's not sufficient, there's the Entityqueue module.

2
  • There are at most 100 terms with 3rd level child. And it might be increase. So change the weight value is not a suitable. Will looks into the Entity Queue. Commented Oct 3, 2018 at 9:33
  • Entityqueue Worked for me. Thank you very much. @sonfd Commented Oct 4, 2018 at 9:08
1

Views Aggregation to count nodes tagged by terms

You can use Views Aggregation to count the number of nodes that each tag is assigned to, and use that as the Sort criteria.

  1. In the Views of type Taxonomy term filter all the terms you're interested about. Add a Name Field to show the term name (you probably already have that covered)
  2. Add a Relationship to the content that the terms are related to Content using field_yourname
  3. Turn on Aggregation (Under Advanced, third column)
  4. Add a Sort criteria Content: Title, (it will automatically use the Relationship from above), Sort descending and adjust its Aggregation settings to Count DISTINCT (if you allow nodes to use multiple terms then Count will count them more than once)

Your terms list will be sorted by the number of nodes tagged by each term in your Views results.

Views Summary for single value fields

If your Taxonomy term reference Field allows for only one value you can use Views summary in a Contextual filter to count the nodes tagged with a term.

You can do it from Taxonomy term Views or Content Views.

  1. If starting from Taxonomy term Views you can use the above steps,
  2. only instead of using Aggregation add a new Contextual filter Name from Taxonomy term Category and configure it to display a Summary:

    When the filter value is NOT available
    Display a summary
    Sort order Descending
    Sort by Number of records
    Format List
    Base path (you must enter the Page path if this isn't the first Page Display in your Views)
    Display record count with link

This way you get a list of Taxonomy terms with node count next to them. When you click on them you go to another page listing the actual Fields you set up in Views (you'll probably want to list Content: Title here).

It's a similar procedure to do that from Content Views type.

  1. You'll want to add a Relationship to the relevant Taxonomy field (Taxonomy term referenced from field_yourname),
  2. then add a Contextual filter for Taxonomy term: Name, use the Relationship and configure it to display as a Summary.
0

To sort Category terms list created using views. We can use EntityQueue.

To do that We need to install the EntityQueue module. Then add a entity Queue for taxonomy terms from : admin/structure/entityqueue

Then add term items to the queue as we want to sort.

From here we can shuffle the queue or change the sorting. After that we need to add an Entityqueue relationship to our view, and adding a sort for Entityqueue position. That way we can achieve the sorting as provided on entity queue.

Note that: We need to make sure the term on the queue list is exist on output of the view.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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