Mark New Nodes in Views via Template I have a portfolio view that displays all items in the portfolio. The fields are set via template so I do not have access to the fields area in views to select the parameter there, I have to do it within my node template.

The issue is I can't figure out what code to stick in there to display the "New" tag if the visitor has not yet viewed the node.

This is the code I have in the template:

&lt;div class="portfolio-name"&gt;
  &lt;h3&gt;&lt;a href="&lt;?php print $node_url?&gt;"&gt;&lt;?php print $title;?&gt;&lt;/a&gt;&lt;/h3&gt;           
  &lt;span&gt;&lt;?php print strip_tags(render($content['field_portfolio_categories'])); ?&gt;&lt;/span&gt;
  &lt;span&gt;&lt;!-- PUT **NEW** FLAG HERE --&gt;&lt;/span&gt;
&lt;/div&gt;


I have googled and found the info here (https://api.drupal.org/api/drupal/includes!theme.inc/function/theme_mark/7) but I just can't figure out how to translate it to what code I put in my actual template file to make it happen.

Thank you so much for your help.



Thank you for your answer!  I am primarily a themer and php just is not my strong suit.  

I have changed my code to be:

&lt;div class="portfolio-name"&gt;
  &lt;h3&gt;&lt;a href="&lt;?php print $node_url?&gt;"&gt;&lt;?php print $title;?&gt;&lt;/a&gt;&lt;/h3&gt;
  &lt;span&gt;&lt;?php print strip_tags(render($content['field_portfolio_categories'])); ?&gt;   &lt;/span&gt;
  &lt;?php
    if (node_last_viewed($node-&gt;nid) &gt; 0) {
       print '&lt;span&gt;' .  theme('mark', array('type' =&gt; MARK_NEW)) . '&lt;/span&gt;';
    }
  ?&gt;             
&lt;/div&gt;


This code displays the "new" text, but only if I am logged in as the administrator and it displays on all items, not just ones I have not visited yet.  Any ideas?
&lt;?php print theme('mark', array('type' =&gt; node_mark($node-&gt;nid, $node-&gt;changed))); ?&gt;


this is how it is done on the content overview page. give it a try, it will display read for anonymous users' - probably ..,

here's the code from node_mark, where node_last_viewed is used:

function node_mark($nid, $timestamp) {
  global $user;
  $cache = &amp;drupal_static(__FUNCTION__, array());

  if (!$user-&gt;uid) {
    return MARK_READ;
  }
  if (!isset($cache[$nid])) {
    $cache[$nid] = node_last_viewed($nid);
  }
  if ($cache[$nid] == 0 &amp;&amp; $timestamp &gt; NODE_NEW_LIMIT) {
    return MARK_NEW;
  }
  elseif ($timestamp &gt; $cache[$nid] &amp;&amp; $timestamp &gt; NODE_NEW_LIMIT) {
    return MARK_UPDATED;
  }
  return MARK_READ;
}


so for you maybe this could be used (statistics module needs to be enabled)

 &lt;?php
      if (node_last_viewed($node-&gt;nid) == 0) {
        print '&lt;span&gt;' .  theme('mark', array('type' =&gt; MARK_NEW)) . '&lt;/span&gt;';
      }


best to call this theme function (and any logic) in the preprocess method, and use a variable in the template ..