comment.tpl.php

  1. 7.x drupal-7.x/modules/comment/comment.tpl.php
  2. 7.x drupal-7.x/themes/garland/comment.tpl.php
  3. 7.x drupal-7.x/themes/bartik/templates/comment.tpl.php
  4. 6.x drupal-6.x/modules/comment/comment.tpl.php
  5. 6.x drupal-6.x/themes/bluemarine/comment.tpl.php
  6. 6.x drupal-6.x/themes/pushbutton/comment.tpl.php
  7. 6.x drupal-6.x/themes/garland/comment.tpl.php

Default theme implementation for comments.

Available variables:

  • $author: Comment author. Can be link or plain text.
  • $content: An array of comment items. Use render($content) to print them all, or print a subset such as render($content['field_example']). Use hide($content['field_example']) to temporarily suppress the printing of a given element.
  • $created: Formatted date and time for when the comment was created. Preprocess functions can reformat it by calling format_date() with the desired parameters on the $comment->created variable.
  • $changed: Formatted date and time for when the comment was last changed. Preprocess functions can reformat it by calling format_date() with the desired parameters on the $comment->changed variable.
  • $new: New comment marker.
  • $permalink: Comment permalink.
  • $submitted: Submission information created from $author and $created during template_preprocess_comment().
  • $picture: Authors picture.
  • $signature: Authors signature.
  • $status: Comment status. Possible values are: comment-unpublished, comment-published or comment-preview.
  • $title: Linked title.
  • $classes: String of classes that can be used to style contextually through CSS. It can be manipulated through the variable $classes_array from preprocess functions. The default values can be one or more of the following:

    • comment: The current template type, i.e., "theming hook".
    • comment-by-anonymous: Comment by an unregistered user.
    • comment-by-node-author: Comment by the author of the parent node.
    • comment-preview: When previewing a new or edited comment.

    The following applies only to viewers who are registered users:

    • comment-unpublished: An unpublished comment visible only to administrators.
    • comment-by-viewer: Comment by the user currently viewing the page.
    • comment-new: New comment since last the visit.
  • $title_prefix (array): An array containing additional output populated by modules, intended to be displayed in front of the main title tag that appears in the template.
  • $title_suffix (array): An array containing additional output populated by modules, intended to be displayed after the main title tag that appears in the template.

These two variables are provided for context:

  • $comment: Full comment object.
  • $node: Node object the comments are attached to.

Other variables:

  • $classes_array: Array of html class attribute values. It is flattened into a string within the variable $classes.

See also

template_preprocess()

template_preprocess_comment()

template_process()

theme_comment()

1 theme call to comment.tpl.php
comment_view in drupal-7.x/modules/comment/comment.module
Generate an array for rendering the given comment.

File

drupal-7.x/modules/comment/comment.tpl.php
View source
  1. <?php
  2. /**
  3. * @file
  4. * Default theme implementation for comments.
  5. *
  6. * Available variables:
  7. * - $author: Comment author. Can be link or plain text.
  8. * - $content: An array of comment items. Use render($content) to print them all, or
  9. * print a subset such as render($content['field_example']). Use
  10. * hide($content['field_example']) to temporarily suppress the printing of a
  11. * given element.
  12. * - $created: Formatted date and time for when the comment was created.
  13. * Preprocess functions can reformat it by calling format_date() with the
  14. * desired parameters on the $comment->created variable.
  15. * - $changed: Formatted date and time for when the comment was last changed.
  16. * Preprocess functions can reformat it by calling format_date() with the
  17. * desired parameters on the $comment->changed variable.
  18. * - $new: New comment marker.
  19. * - $permalink: Comment permalink.
  20. * - $submitted: Submission information created from $author and $created during
  21. * template_preprocess_comment().
  22. * - $picture: Authors picture.
  23. * - $signature: Authors signature.
  24. * - $status: Comment status. Possible values are:
  25. * comment-unpublished, comment-published or comment-preview.
  26. * - $title: Linked title.
  27. * - $classes: String of classes that can be used to style contextually through
  28. * CSS. It can be manipulated through the variable $classes_array from
  29. * preprocess functions. The default values can be one or more of the following:
  30. * - comment: The current template type, i.e., "theming hook".
  31. * - comment-by-anonymous: Comment by an unregistered user.
  32. * - comment-by-node-author: Comment by the author of the parent node.
  33. * - comment-preview: When previewing a new or edited comment.
  34. * The following applies only to viewers who are registered users:
  35. * - comment-unpublished: An unpublished comment visible only to administrators.
  36. * - comment-by-viewer: Comment by the user currently viewing the page.
  37. * - comment-new: New comment since last the visit.
  38. * - $title_prefix (array): An array containing additional output populated by
  39. * modules, intended to be displayed in front of the main title tag that
  40. * appears in the template.
  41. * - $title_suffix (array): An array containing additional output populated by
  42. * modules, intended to be displayed after the main title tag that appears in
  43. * the template.
  44. *
  45. * These two variables are provided for context:
  46. * - $comment: Full comment object.
  47. * - $node: Node object the comments are attached to.
  48. *
  49. * Other variables:
  50. * - $classes_array: Array of html class attribute values. It is flattened
  51. * into a string within the variable $classes.
  52. *
  53. * @see template_preprocess()
  54. * @see template_preprocess_comment()
  55. * @see template_process()
  56. * @see theme_comment()
  57. *
  58. * @ingroup themeable
  59. */
  60. ?>
  61. <div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
  62. <?php print $picture ?>
  63. <?php if ($new): ?>
  64. <span class="new"><?php print $new ?></span>
  65. <?php endif; ?>
  66. <?php print render($title_prefix); ?>
  67. <h3<?php print $title_attributes; ?>><?php print $title ?></h3>
  68. <?php print render($title_suffix); ?>
  69. <div class="submitted">
  70. <?php print $permalink; ?>
  71. <?php print $submitted; ?>
  72. </div>
  73. <div class="content"<?php print $content_attributes; ?>>
  74. <?php
  75. // We hide the comments and links now so that we can render them later.
  76. hide($content['links']);
  77. print render($content);
  78. ?>
  79. <?php if ($signature): ?>
  80. <div class="user-signature clearfix">
  81. <?php print $signature ?>
  82. </div>
  83. <?php endif; ?>
  84. </div>
  85. <?php print render($content['links']) ?>
  86. </div>

Related topics