drupal development. drupal support. drupal training.

Format the "Submitted by..." text for Drupal 6 nodes and comments

Published on Wed, 2008-07-30 17:43

I don't like the way Drupal formats the "Submitted by..." text for nodes and comments. So, I did a little bit of digging and found the offending code in the theme_node_submitted() and theme_comment_submitted() functions of node.module and comment.module respectively. These two functions are easy to override at the theme level by making a copy in your template.php file, and renaming the function to fit with your theme (replace theme with the name of your theme). I made mine look like this:

function kirkdesigns_node_submitted($node) {
  return t('Posted by !username on @date', array(
    '!username' => theme('username', $node),
    '@date' => format_date($node->created, 'custom', 'd M Y')
  ));
}

That took care of the "submitted by..." for all of my nodes. And the following snippet took care of the comments:

function kirkdesigns_comment_submitted($comment) {
  return t('Posted by !username on @date at about @time.', array(
    '!username' => theme('username', $comment),
    '@date' => format_date($comment->timestamp, 'custom', 'd M Y'),
    '@time' => format_date($comment->timestamp, 'custom', 'H:i')
  ));
}

It's only a small change, but it's the little things that make the difference.

Comments

Submitted by Anonymous (not verified) on

I"ve put this into my template.php file and it is not changing the output of my node pages. Do you have to call then function from some place for this to work? 

Add new comment