5

Objective: Override comment.tpl.php file output in drupal core modules.

Assumption: My best guess is that I need to create a comment-[type].tpl.php file in my themes folder.

Requirements:

  • template.php can not be used
  • need to replace default comment.tpl.php html output

Questions:

  • how do i find the so called type of the comment for the tpl file?
  • is this the best way to change the html output of the file?
  • is there another way to change the output with the type or using template.php?

Links: http://drupal.org/node/190815

migrated from stackoverflow.com May 29 '12 at 6:29

This question came from our site for professional and enthusiast programmers.

8

You should be able to override Drupal's default comment.tpl.php file by copying it from /modules/comment into your theme directory. From there, edit the file as needed. Then clear the cache (on the Admin > Site configuration > Performance), so that the theme cache will get rebuilt and your new theme file will get recognized.

You would only need to rename comment.tpl.php to comment-[type].tpl.php, if you wanted to override comment theming differently for different node types.

  • I'm having trouble getting this to work. I have cleared caches and i get nothing. Restarted PC, cleared browser cache and dns – Kevin Jan 27 '11 at 13:27
  • could i be having issues because a module may be overriding the comment.tpl too? I thought themes have higher override – Kevin Jan 27 '11 at 14:08
  • 1
    Try installing the Devel Themer module, which should provider you more information on what theme files are being used for different areas of the site: drupal.org/project/devel_themer – Matt V. Jan 27 '11 at 15:23
  • awesome thanks. i know this should work but im just having a time with it. – Kevin Jan 27 '11 at 15:45

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