Popular tags view active class I have a view which is a HTML list of the most popular tags in a specific vocabulary it is displayed as a block on a page of most recent news items. It is also displayed on each individual news item. 

When it is displayed on the individual news item page I would like any tag that the news item has been tagged with and that also appears in the popular tags block to be highlighted by adding a css class called active.

How would I achieve this?
Well, the only method I can think of is to do it the template, but have a feeling there must be a better solution than this... But to do it this way:

Edit your view and under Advanced click on Theme: Information. This shows a list of template file names that would apply to your view. If you had a view called tags then creating a template file called views-view-fields--tags.tpl.php would be appropriate. After adding your template file (in your themes directory) click the Rescan template files button.

The standard template file looks like this:

&lt;?php foreach ($fields as $id =&gt; $field): ?&gt;
  &lt;?php if (!empty($field-&gt;separator)): ?&gt;
    &lt;?php print $field-&gt;separator; ?&gt;
  &lt;?php endif; ?&gt;

  &lt;?php print $field-&gt;wrapper_prefix; ?&gt;
    &lt;?php print $field-&gt;label_html; ?&gt;
    &lt;?php print $field-&gt;content; ?&gt;
  &lt;?php print $field-&gt;wrapper_suffix; ?&gt;
&lt;?php endforeach; ?&gt;


But if you changed it to this:

&lt;?php foreach ($fields as $id =&gt; $field): ?&gt;
&lt;?php if (!empty($field-&gt;separator)): ?&gt;
&lt;?php print $field-&gt;separator; ?&gt;
&lt;?php endif; ?&gt;
&lt;?php print $field-&gt;wrapper_prefix; ?&gt;
&lt;?php print $field-&gt;label_html; ?&gt;
&lt;?php 
$current = false;
if(arg(0)=='node' &amp;&amp; is_numeric(arg(1))) { // check if we are on a node page
    $node = node_load(arg(1)); // load the node
    $tag = strip_tags($field-&gt;content);
    foreach($node-&gt;field_tags[LANGUAGE_NONE] as $term) { // loop over the tags attached to the node
        if($term['taxonomy_term']-&gt;name == $tag) { // there is a match
            $current = true;
            break;
        }
    }
}
if($current) {
    print '&lt;span class="current"&gt;'.$field-&gt;content.'&lt;/span&gt;'; // add a span with current class
} else {
    print $field-&gt;content; 
}
?&gt;
&lt;?php print $field-&gt;wrapper_suffix; ?&gt;
&lt;?php endforeach; ?&gt;


The disadvantage of this method it that code needs to run for each tag in the list, but it would achieve the desired result.