Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 610 Vote(s) - 3.57 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to display only taxonomy terms with nodes associated to in Views 2?

#1
I've created a view with a set filters exposed (to show filtering options in the page). And one of those filters is a select field with all the taxonomy terms of a vocabulary.

That's ok, it's showing now. But I want to only show the taxonomy terms that have at least one node associated to it. To avoid empty results if selects an empty term.

Anyone knows how to do that?

Thanks.
Reply

#2
This would be a great feature for Views to have and you should submit a feature request to the maintainers for it. Unfortunately you can't do this with the existing Views code.

\What you could do, though, is see how Views constructs a filter control in its own source code, and implement that function yourself and add in an extra check to see if there are any posts with that term or not, and not display that term if there aren't any.
Reply

#3
Solution in views 3 (which may work in views 2)

Set a relationship for the view to join the terms to the nodes (in views 3 this is 'Taxonomy term: Content with term')

Then in the options tick 'Require this relationship' (this excludes terms without any nodes)

This may produce duplicates, in views 3 you open up Query settings, and tick Distinct (this will omit duplicates)

Reply

#4
With views 3 this gets very simple using aggregation! I'm posting this replay because I spent a lot of time discovering it. Everything is very well explained in this screencast:

[To see links please register here]

Reply

#5
This is a simpler way. Hope it helps.

Add a relationship, filter for terms and choose "Taxonomy term: Representative node". Check the "require this relationship" and thats it. Optionally tick "Query settings > Distinct" in case of duplicate terms.

Based on

[To see links please register here]

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through