Posted by webchick on May 10, 2007 at 4:13am
9 followers
| Project: | Drupal core |
| Version: | 6.x-dev |
| Component: | theme system |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
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.
Comments
#1
Here's a patch.
#2
Simple and straightforward. I see no reason not to just RTBC it.
#3
Just giving my BIG +1 to this one!
#4
Thanks, folks! Assigning to myself so I can keep track of this.
#5
Big +1 on the functionality too.
#6
If this gets in, it'll be easier to prepare a patch for flatforum for drupal 6. i.e. bumping :D
#7
Oooh, I like this. +1 from me. :)
Michelle
#8
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.
#9
No, the recent comments block does not do a theme('comment').
<?phpfunction 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);
}
}
?>
#10
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.
#11
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.
#12
nice one. i agree that we are safe for comment block and don't need anything beyond the patch in #1
#13
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.
#14
Does this look good?
#15
Nice patch!
Reviewing atm...
#16
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.. :-)
#17
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.
#18
Thanks for committing it!!
Do you mean the basic styling for forum comments?
#19
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
#20