Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#14 | drupal6-feature_comment_type.patch | 7.9 KB | Gurpartap Singh |
#10 | comment-type_0.patch | 3.1 KB | webchick |
#1 | comment-type.patch | 1.13 KB | webchick |
Comments
Comment #1
webchickHere's a patch.
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commentedSimple and straightforward. I see no reason not to just RTBC it.
Comment #3
morphir CreditAttribution: morphir commentedJust giving my BIG +1 to this one!
Comment #4
webchickThanks, folks! Assigning to myself so I can keep track of this.
Comment #5
kbahey CreditAttribution: kbahey commentedBig +1 on the functionality too.
Comment #6
Gurpartap Singh CreditAttribution: Gurpartap Singh commentedIf this gets in, it'll be easier to prepare a patch for flatforum for drupal 6. i.e. bumping :D
Comment #7
MichelleOooh, I like this. +1 from me. :)
Michelle
Comment #8
Dries CreditAttribution: Dries commentedOne 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.
Comment #9
merlinofchaos CreditAttribution: merlinofchaos commentedNo, the recent comments block does not do a theme('comment').
Comment #10
webchickThe 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.
Comment #11
merlinofchaos CreditAttribution: merlinofchaos commentedI 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.
Comment #12
moshe weitzman CreditAttribution: moshe weitzman commentednice one. i agree that we are safe for comment block and don't need anything beyond the patch in #1
Comment #13
Dries CreditAttribution: Dries commentedPersonally, 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.
Comment #14
Gurpartap Singh CreditAttribution: Gurpartap Singh commentedDoes this look good?
Comment #15
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedNice patch!
Reviewing atm...
Comment #16
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedSorry, 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.. :-)
Comment #17
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. I'm marking this as 'code needs work' because I don't think it fully implements the original patch's needs.
Comment #18
Gurpartap Singh CreditAttribution: Gurpartap Singh commentedThanks for committing it!!
Do you mean the basic styling for forum comments?
Comment #19
webchickThe 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
Comment #20
(not verified) CreditAttribution: commented