Simpler author / date / comment links

Last modified: August 26, 2009 - 18:34

This is a very simple modification to the code you use in node.tpl.php so you can display your author/date/comments metadata a minimally.

If you want this:

By jibbajabba on 21 Feb | 1 comment

Rather than something like this:

February 21, 2007 - 10:06am
jibbajabba's blog | 1 comment

You can use this snippet in your node.tpl.php file:

By <?php print $name; ?> on <?php print format_date($node->created, 'custom', 'd M'); ?> |
<?php
 
print $node->comment_count . ' comment';
  if (
$node->comment_count != 1) { print 's'; }
?>

Clean-up

Chill35 - June 16, 2008 - 22:37

Better use http://api.drupal.org/api/function/format_plural/.

Better leave the node object alone, as much as possible.

Use $name instead of $node->name to get a link in the right context.

By <?php print $name; ?> on <?php print format_date($created, 'custom', 'd M'); ?> | <?php print format_plural($comment_count, '1 comment', '@count comments'); ?>

 
 

Drupal is a registered trademark of Dries Buytaert.