Just as we allow node-$type.tpl.php, we should also allow comment-$type.tpl.php... for instance, we might want to theme blog comments so that the author's reply is highlighted. We might want to theme forum comments so that they appear in a 'table-like' structure like PHPBB.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

webchick’s picture

Status: Active » Needs review
FileSize
1.13 KB

Here's a patch.

merlinofchaos’s picture

Status: Needs review » Reviewed & tested by the community

Simple and straightforward. I see no reason not to just RTBC it.

morphir’s picture

Just giving my BIG +1 to this one!

webchick’s picture

Assigned: Unassigned » webchick

Thanks, folks! Assigning to myself so I can keep track of this.

kbahey’s picture

Big +1 on the functionality too.

Gurpartap Singh’s picture

If this gets in, it'll be easier to prepare a patch for flatforum for drupal 6. i.e. bumping :D

Michelle’s picture

Oooh, I like this. +1 from me. :)

Michelle

Dries’s picture

One question -- does this code get triggered when loading the recent comments block? If so, it would add x node loads to the page view where x is likely to be 10.

This patch looks good, but maybe double-check to see whether that node_load is _really_ needed. It's an expensive call if the only thing you need is the node's type.

merlinofchaos’s picture

No, the recent comments block does not do a theme('comment').

function theme_comment_block() {
  $items = array();
  foreach (comment_get_recent() as $comment) {
    $items[] = l($comment->subject, 'node/'. $comment->nid, NULL, NULL, 'comment-'. $comment->cid) .'<br />'. t('@time ago', array('@time' => format_interval(time() - $comment->timestamp)));
  }
  if ($items) {
    return theme('item_list', $items);
  }
}
webchick’s picture

FileSize
3.1 KB

The alternative to the node_load is this approach, which appends a $comment->type property. Unfortunately, there is no single place to do this, so it needs to be added to the code about 50 times. It still requires a node_load in preview, but otherwise can take it from the $node object already in scope.

merlinofchaos’s picture

I don't think an alternative to node_load is necessary, or a good idea. theme('comment') is only called, in Drupal, when something is known about the node.

moshe weitzman’s picture

nice one. i agree that we are safe for comment block and don't need anything beyond the patch in #1

Dries’s picture

Status: Reviewed & tested by the community » Needs work

Personally, I'd be more leaning towards having a solution where both the $comment and the $node object are passed into the various theme functions. Looking at the code, this seems like this might require a bit more work but it will be more elegant/transparent in the end.

Gurpartap Singh’s picture

Status: Needs work » Needs review
FileSize
7.9 KB

Does this look good?

Stefan Nagtegaal’s picture

Nice patch!
Reviewing atm...

Stefan Nagtegaal’s picture

Status: Needs review » Reviewed & tested by the community

Sorry, I hitted the Submit button faster than I had planned todo.
This works pretty well, and gives us *a lot* more interesting things to keep in mind when theming!

Code looks also clean and straight forward! Tested on my local copy of head and did some modification to Garland to see if thing work like I expected..

It does, no need to hold this up any longer.. :-)

Dries’s picture

Status: Reviewed & tested by the community » Needs work

Committed to CVS HEAD. I'm marking this as 'code needs work' because I don't think it fully implements the original patch's needs.

Gurpartap Singh’s picture

Thanks for committing it!!

Do you mean the basic styling for forum comments?

webchick’s picture

Assigned: webchick » Unassigned
Status: Needs work » Fixed

The purpose of this patch was to make flat forum styling possible, so since there's a patch for that now I think it's ok to mark this fixed.

I documented the change at Converting 5.x themes to 6.x

Anonymous’s picture

Status: Fixed » Closed (fixed)