0

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; ?>
1

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. :-)

  • 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
0

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

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.