1

I am rendering comments on my site. I am using the Zen theme. If I remark out <?php print $submitted; ?> in comment.tpl.php the 'username replied on' part is no longer rendered. But I don't want to remove the whole thing - just the 'replied on' text. I can't work out how to alter this bit. Thanks

In Zen comment.tpl.php it reads: '$submitted: Submission information created from $author and $created during template_preprocess_comment()'. Presumably, somewhere there will be: $author . 'replied on' - and this is what I need to alter.

  • The easiest way to do this by string override. you can use string override module for this. And text probably be coming from templete_preprocess_comment() must be wrapped in t(). – nit3ch Apr 23 '13 at 10:46
  • Try is.gd/WUyhD3 with hook_preprocess_comment(). – AyeshK Apr 23 '13 at 20:07
3

Solution

A solution is to not use $submitted, but to use $author and $created separately in comment.tpl.php.

2

you could override theme_comment_submitted()

    function yourtheme_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')
  ));
}

but the way I prefer is instead of using $submitted try using $author and $created along some words you rather to use.

on the other hand the easiest and not recommended way to do this is to use locale module, and then translate it to the same language you have but with the words you want!

  • I would like to give a -1 for the locale-based solution, and a +1 for the theme_comment_submitted(), so that adds up to 0. Translations are not meant for string overrides or other theme-related changes. – marcvangend Apr 23 '13 at 11:35
  • well ofcourse the locale-base solution is not the right way to do it but still works! – Sohail Apr 24 '13 at 5:20
  • 1
    Sure it works, but IMHO you shouldn't advocate the wrong method. If you do want to mention it, I would put it at the end of my answer and add a "this is not recommended" warning. – marcvangend Apr 25 '13 at 10:11
  • 1
    yea good point, I should edit that, but still there were lots of situations I used not recommended version just to get sth to work, so I think it always worth to mention – Sohail Apr 25 '13 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.