Community Documentation

Simpler author / date / comment links

Last updated August 26, 2009. Created by ugerhard on February 23, 2007.
Edited by ronald_istos, sepeck, jibbajabba. Log in to edit this page.

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'; }
?>

Comments

Clean-up

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'); ?>

About this page

Drupal version
Drupal 5.x

Theming Guide

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.