Show if there are 'new' comments on a view of terms? I have comments on nodes that are categorised by terms. I need to show a view of the terms and if there are any new comments in any of the nodes that term is tagged with.

So if I have the following: 

Term1
-NodeA (has new comments)
-NodeB (has new comments) 
Term2
-NodeC (no new comments) 
-NodeD (no new comments) 
Term3
-NodeE (no new comments) 
-NodeF (has new comments)
Term4


I need my view to look like this:

Term1 – new comments!
Term2
Term3 – new comments!
Term4


First I tried making a view of comments to include the new comments field and using relationships to show the terms. However if a term has no nodes or comments (Term4 in my example) I need the term to still be displayed. 

So I then tried making a view of the terms. I added the relationships 'Taxonomy term: Content with term' and the field 'Content: New comments' which uses this relationship. This does show the number of new comments as expected. It gives me duplicated results (which I may be able to fix with grouping fields) but unexpectedly it also hides the terms that have no comments or nodes. 

Am I going about this the right way and if so how can I stop the 'empty' terms being hidden? 

UPDATE Ive updated D core and a few modules that had new versions (but not views). The view works fine with the relationship of 'Configure Relationship: Taxonomy term: Content with term' when the field is 'Content: Title (Title)'. However when I add the field 'Content: New comments' then terms that have no comments are hidden. 

UPDATE Ive tried the following in a views field: 

if(intval($data-&gt;node_new_comments) &gt; 0) {
  if(!array_key_exists($data-&gt;tid, $static)) {
    print "new comments !";
    $static[$data-&gt;tid] = 1;
  }
} else {
  print "here you do whatever you want when there's no new comment";
}


UPDATE - by 'new comments' I mean comments that the logged in user hasnt read. This is a standard field in views. I need this rather than an arbitrary date cut off. Sorry for any confusion.
This works for me. I have a term view that shows the term name field and my code adds the new comment flag after the term name.

The code goes in a custom module.

You need to change to VIEW_NAME to your view name and the TAXONOMY_FIELD_NAME to the name of your field (like field_tags for example).

/**
 * Implements hook_views_pre_render().
 */
function MYMODULE_views_pre_render(&amp;$view) {
  global $user;
  if ($view-&gt;name == 'VIEW_NAME' &amp;&amp; $user-&gt;uid) {
    // Get all the tids of the views results.
    $tids = array();
    foreach ($view-&gt;result as $result) {
      $tids[] = $result-&gt;tid;
    }

    // Get all the tids that have recent comments.
    // Only return terms that relate to nodes that have not been viewed by
    // the current user since the last comment.
    $query = db_query("SELECT t.TAXONOMY_FIELD_NAME_tid
                         FROM {node_comment_statistics} c
              LEFT OUTER JOIN {history} h ON c.nid = h.nid AND h.uid = :uid
                   INNER JOIN {field_data_TAXONOMY_FIELD_NAME} t ON t.entity_id = c.nid
                        WHERE c.comment_count &gt; 0
                          AND t.TAXONOMY_FIELD_NAME_tid IN (:tids)
                          AND (h.timestamp IS NULL OR h.timestamp &lt; c.last_comment_timestamp)",
               array(':uid' =&gt; $user-&gt;uid, ':tids' =&gt; $tids));
    $commented_terms = $query-&gt;fetchCol();

    // Loop through the results and add the new comments flag where necessary.
    foreach ($view-&gt;result as &amp;$result) {
      if (in_array($result-&gt;tid, $commented_terms)) {
        $result-&gt;taxonomy_term_data_name .= ' new comments!';
      }
    }
  }
}