In the node template file (node.tpl.php) you could determine whether the node creation timestamp ($node->created) is still classed as new by comparing it to the php time() function (http://ca.php.net/manual/en/function.time.php). Then use an 'if' statement to show the 'new' text or graphic in the place which you would like it. Here is some code which would go in node.tpl.php or node-type.tpl.php (where 'type' is the content type in question).
## IS POST NEW? ##
#current time using php time() funciton:
$current_time = time();
#time of post is from $node variable:
$post_time = $node->created;
#length of 'new' status is for 1 week in this example (60 seconds x 60 mins x 24 hours x 7 days):
$new_duration = 60*60*24*7;
#calculate time difference between current time and time of post:
$difference = $current_time - $post_time;
#if the difference between current and post time is less than the specified 'new' duration, it's a NEW post!
if($difference < $new_duration) {
print 'NEW';
}
Comments
No news yet?
No solutions yet?
me too
I'd like to be able to do this too.
How long are things 'new'
How long are things 'new' for?
In the node template file (node.tpl.php) you could determine whether the node creation timestamp ($node->created) is still classed as new by comparing it to the php time() function (http://ca.php.net/manual/en/function.time.php). Then use an 'if' statement to show the 'new' text or graphic in the place which you would like it. Here is some code which would go in node.tpl.php or node-type.tpl.php (where 'type' is the content type in question).
Hope this is helpful.