Find out if a view returns any results and if it doesn't disable a link to that view 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.
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.