I have a panels page with two view panes on it. The first view pane lists taxonomy terms. When you click on one of the taxonomy terms the second view pane will display a list of content for that taxonomy term.

Is there any way that if there is no content for one or more of the taxonomy terms then those links can be disabled/hidden from the first view pane?

The second view pane uses the term ID from the links in the first view pane as an argument to filter the content for that term.

I'm not quite sure how to go about doing this. One way I had thought was to use jQuery and Ajax to somehow call a function in Drupal to find out if the view returned any result and then hide the link. But I haven't attempted this before in Drupal.

There is another slight complication in that the panels display are for organic groups and the second view pane only shows content for the taxonomy term clicked on and also content that is associated with that group. So that any function that finds if there are any results would need to pass in both the argument for the term ID and also the ID for the group, which the view was getting from the context.

Any help would be much appreciated, or even an outline of an approach I could take.

2 Answers 2


The one solution is hide empty terms. You can hide empty terms as shown here

Another solution is use php in your view or views template, use taxonomy_select_nodes function.

Return nodes attached to a term across all field instances.

The tid can get from view. If the function return empty , dont provide link for that term.

Otherwise you can link term to your second view.

  • Hi Anoop, thanks for your answer. I'll try it out and let you know how I get on.
    – Ben
    Commented May 17, 2013 at 11:00
  • I managed to use the first method using representative node. This was partially successful. It worked for two views that were based on taxonomy vocabularies which only applied to a single content type. For two other views, where the vocabulary applied to more than one content type I ran into errors and could not get it to work. I needed to use a representative view to get it to work but there seems to be an issue (drupal.org/node/1417090) with this. I'm not sure how to overcome this, and having looked at the second option you suggest, I'm not sure how I would implement it.
    – Ben
    Commented May 18, 2013 at 10:42
  • Hi Anoop, unfortunately, the top answer you provided, after I implemented it, did not produce consistent results and so I had to replace all the views I was using with the solution that I implemented below.
    – Ben
    Commented May 29, 2013 at 8:03

I managed to get the results I was looking for by using a different kind of view. I created a term view and added a relationship for "content with term", and a second relationship for "group membership" based on the first relationship. I then added in a filter for the content type, and a context filter for the group. I only added a field for the term and in the query settings made the query distinct. The view now only shows distinct terms which relate to content of a specific type and that [the content] belong to a specific group.

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.