2

Is there a hook I can use to alter the way comments are rendered? Not for altering the comments form, but the listed comments themselves. Obviously, I can target with CSS, but I was wondering if I can hook into core and change the way they are displayed from there?

Thanks

2

You can use hook_comment_view():

The comment is being viewed. This hook can be used to add additional data to the comment before theming.

e.g.

function hook_comment_view($comment, $view_mode, $langcode) {
  // how old is the comment
  $comment->time_ago = time() - $comment->changed;
}

Or use a standard theme preprocess hook

function MYTHEME_preprocess_comment(&$vars) {
  // Make changes to $vars that will be available in comment.tpl.php
}

You can also override the standard comment.tpl.php file in your theme to have full control over the markup.

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.