I would like to have a heading over my comments that only appears after a comment has been left... I tried the code below but it doesn't seem to be the answer:

<?php if ($comment): ?>
    <h2>Comments</h2>
<?php endif; ?>
link|improve this question

78% accept rate
feedback

2 Answers

up vote 1 down vote accepted

This is the default behavior of Garland. Have a look in the themes/garland/template.php file:

function garland_preprocess_comment_wrapper(&$vars) {
  if ($vars['content'] && $vars['node']->type != 'forum') {
    $vars['content'] = '<h2 class="comments">'. t('Comments') .'</h2>'.  $vars['content'];
  }
}

Where did you put your code? Depending on your theme, you most probably want to theme comment-wrapper.tpl.php, which only gets output when there are comments to be displayed. Which what you want. :-)

link|improve this answer
Thanks, I was hoping for something a tad easier to implement but I guess there is no such solution at this time. Think it would be something good to include in future Drupal core releases though. – Jane Aug 27 '11 at 16:12
feedback

seems that you can add your conditional in a preprocess function, please see "Altering the 'Post new comment' heading" part in: http://www.systemseed.com/blog/how-customise-comment-form-drupal-6

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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