comment.tpl.php

  1. drupal
    1. 4.7 themes/bluemarine/comment.tpl.php
    2. 4.7 themes/pushbutton/comment.tpl.php
    3. 4.7 themes/engines/phptemplate/comment.tpl.php
    4. 5 themes/engines/phptemplate/comment.tpl.php
    5. 5 themes/bluemarine/comment.tpl.php
    6. 5 themes/garland/comment.tpl.php
    7. 5 themes/pushbutton/comment.tpl.php
    8. 6 themes/bluemarine/comment.tpl.php
    9. 6 modules/comment/comment.tpl.php
    10. 6 themes/pushbutton/comment.tpl.php
    11. 6 themes/garland/comment.tpl.php
    12. 7 themes/bartik/templates/comment.tpl.php
    13. 7 modules/comment/comment.tpl.php
    14. 7 themes/garland/comment.tpl.php
    15. 8 core/modules/comment/comment.tpl.php
    16. 8 core/themes/bartik/templates/comment.tpl.php

Bartik's theme implementation for comments.

Available variables:

  • $author: Comment author. Can be a 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: unpublished, published, or 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; e.g., 'theming hook'.
    • by-anonymous: Comment by an unregistered user.
    • by-node-author: Comment by the author of the parent node.
    • preview: When previewing a new or edited comment.

    The following applies only to viewers who are registered users:

    • unpublished: An unpublished comment visible only to administrators.
    • by-viewer: Comment by the user currently viewing the page.
    • new: New comment since the last 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 entity 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()

File

core/themes/bartik/templates/comment.tpl.php
View source
  1. <?php
  2. /**
  3. * @file
  4. * Bartik's theme implementation for comments.
  5. *
  6. * Available variables:
  7. * - $author: Comment author. Can be a link or plain text.
  8. * - $content: An array of comment items. Use render($content) to print them
  9. * all, or 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
  21. * during template_preprocess_comment().
  22. * - $picture: Authors picture.
  23. * - $signature: Authors signature.
  24. * - $status: Comment status. Possible values are:
  25. * unpublished, published, or 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
  30. * following:
  31. * - comment: The current template type; e.g., 'theming hook'.
  32. * - by-anonymous: Comment by an unregistered user.
  33. * - by-node-author: Comment by the author of the parent node.
  34. * - preview: When previewing a new or edited comment.
  35. * The following applies only to viewers who are registered users:
  36. * - unpublished: An unpublished comment visible only to administrators.
  37. * - by-viewer: Comment by the user currently viewing the page.
  38. * - new: New comment since the last visit.
  39. * - $title_prefix (array): An array containing additional output populated by
  40. * modules, intended to be displayed in front of the main title tag that
  41. * appears in the template.
  42. * - $title_suffix (array): An array containing additional output populated by
  43. * modules, intended to be displayed after the main title tag that appears in
  44. * the template.
  45. *
  46. * These two variables are provided for context:
  47. * - $comment: Full comment object.
  48. * - $node: Node entity the comments are attached to.
  49. *
  50. * Other variables:
  51. * - $classes_array: Array of html class attribute values. It is flattened
  52. * into a string within the variable $classes.
  53. *
  54. * @see template_preprocess()
  55. * @see template_preprocess_comment()
  56. * @see template_process()
  57. * @see theme_comment()
  58. *
  59. * @ingroup themeable
  60. */
  61. ?>
  62. <div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
  63. <div class="attribution">
  64. <?php print $user_picture; ?>
  65. <div class="submitted">
  66. <p class="commenter-name">
  67. <?php print $author; ?>
  68. </p>
  69. <p class="comment-time">
  70. <?php print $created; ?>
  71. </p>
  72. <p class="comment-permalink">
  73. <?php print $permalink; ?>
  74. </p>
  75. </div>
  76. </div>
  77. <div class="comment-text">
  78. <div class="comment-arrow"></div>
  79. <?php if ($new): ?>
  80. <span class="new"><?php print $new; ?></span>
  81. <?php endif; ?>
  82. <?php print render($title_prefix); ?>
  83. <h3<?php print $title_attributes; ?>><?php print $title; ?></h3>
  84. <?php print render($title_suffix); ?>
  85. <div class="content"<?php print $content_attributes; ?>>
  86. <?php
  87. // We hide the comments and links now so that we can render them later.
  88. hide($content['links']);
  89. print render($content);
  90. ?>
  91. <?php if ($signature): ?>
  92. <div class="user-signature clearfix">
  93. <?php print $signature; ?>
  94. </div>
  95. <?php endif; ?>
  96. </div> <!-- /.content -->
  97. <?php print render($content['links']); ?>
  98. </div> <!-- /.comment-text -->
  99. </div>

Related topics

Login or register to post comments