In complex theming, it's nice to have all the comments located within a single div, or some more complex style. A two line patch of the comment module and some additions to template.php allow for using a comment_header.tpl and comment_footer.tpl.

Here are the additions to template.php

function phptemplate_comment_header() {
  return _phptemplate_callback('comment_header');
}

function phptemplate_comment_footer() {
  return _phptemplate_callback('comment_footer');
}

Comments

Steven’s picture

I think instead of header and footer we should just have a single theme function which wraps all the comments. Then it can be themed in one place. Good patch though, there is a theming gap here that needs to be filled.

Can you submit a complete, unified diff with fixes?
http://drupal.org/patch

arthurf’s picture

StatusFileSize
new678 bytes

Woops, sorry about the bad diff. Here's another go.

arthurf’s picture

Title: Wrap comments in single div » Single template wrap
StatusFileSize
new3.1 KB

Ok, based on your comments, I redid the process a bit to wrap the comments in a single template called comment_wrapper. Here's the code for template.php:

function phptemplate_comment_wrapper($content) {
  return _phptemplate_callback('comment_wrapper', array('content' => $content));
}

and here's a new patch for the comment module. 1 line, hooray!

markus_petrux’s picture

Status: Needs review » Needs work

It looks like this patch is not taken from latest CVS version?

arthurf’s picture

Title: Single template wrap » Patched against HEAD
StatusFileSize
new304 bytes

Woops, you got me on that. Here's the patch against the HEAD version of the comment.module

chx’s picture

Title: Patched against HEAD » Single template wrap
arthurf’s picture

StatusFileSize
new1.24 KB

This an additional patch that doesn't call the comment_wrapper if there are no comments. I'm not sure if its useful, or if my catch is a good one, given the extra db hit.

if (db_num_rows($result) > 0) {
    $output = theme('comment_wrapper', $output );
  }
pfaocle’s picture

Version: 4.7.0-rc3 » x.y.z
LAsan’s picture

Version: x.y.z » 7.x-dev

Still applies to current version?

If not, fell free to close topic.

casey’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.