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.
I am working on patch to add this functionality after greggles asked me to take a shot at it during drupalcon.
Comment | File | Size | Author |
---|---|---|---|
#29 | dim-comments-v9.patch | 4.1 KB | marvil07 |
#19 | 781546_dim_vud_comments6.patch | 5.04 KB | realityloop |
#17 | 781546_dim_vud_comments5.patch | 6.84 KB | realityloop |
#15 | 781546_dim_vud_comments4.patch | 6.99 KB | realityloop |
#12 | 781546_dim_vud_comments3.patch | 6.74 KB | realityloop |
Comments
Comment #1
realityloopI'm not sure how to make $vote_count accesible from vud_comment.module, how would I pass the variable which is abailable in vud.theme.inc to vud_comment.module?
Comment #2
marvil07 CreditAttribution: marvil07 commentedThere is a
$points
variable inside the widget template(retrieved onvud_widget_proxy()
), which is calculated using:So, what we need to do is set a class on comment depending on
vote_result
value.Comment #3
realityloopI'm almost done at the moment getting static hides in place, I aim to make the cutoff point configurable once this issue is sorted.
I just need help with making $vote_count variable available in vud_comment.module. see TODO comment at line 75
Comment #4
realityloopPatch attached with settings for Trigger point for dimmed comments.
I still need help with making $vote_count variable available in vud_comment.module though. see TODO comment at line 81 of vud_comment.module after applying patch.
Comment #5
gregglesHere's an updated patch (untested) but I think it should work.
Comment #6
realityloopThanks greggles that didn't work here, but led me to a working solution.
Working patch attached, also did some cleanup of other files as recommended by Coder.
Comment #7
jcisio CreditAttribution: jcisio commentedI think there is a solution better than override the comment theme (there are themes with customized comment.tpl.php already). The collapsed part is great. Why just make the comment
$content
collapsible? It's even better if there is a text "click here to show the comment", when clicking on it, the text will be replaced with the content. But I don't know if something like that is available, or is it easy to implement with jQuery.There are also some debug code in the last patch:
($comment->cid > 89654 && strpos($base_url, 'groups')) || ($comment->cid > 1266382)
Comment #8
gregglesThat's not debug code, it's for the drupal.org theme. realityloop is working on this in part for groups.drupal.org (which is awesome of him) so his code may include some site specific things which should not be committed to the main project directly.
Comment #9
realityloopAs per greggles comment marking this as needs review again so marvil07 or lut4rp will review
Comment #10
marvil07 CreditAttribution: marvil07 commentedThanks for the work here.
It would be great if you split the patch in two: one in this issue for the relevant code, and other in #786902: Review code with coder about code standards.
The patch works only if I use the proposed comment template in my theme(garland by default overwrite comment.tpl.php). It seems like the only way to accomplish that because there is not a
$classes
variable inside the comment. I'm not really convinced about that solution.Other alternatives(making the decision in the theme preprocess function instead of inside the comment template) could be:
- define a theme variable for comment.tpl.php template, and let the user put that variable in his template.
- hack the
$status
variable to include the relevant class.But those are neither "good" solutions, so I'm open for suggestions.
About css it seems to the only way to get cross-browser opacity now, so great.
Naturally, please do not include g.d.o custom code in the patch.
I suppose I need more feedback about the right way to "dim" irrelevant comments, so opacity is a good option, but auto-collapse could be another one(kind of what slashdot use). So if someone has more options about that, please join the discussion :-)
Comment #11
jcisio CreditAttribution: jcisio commentedI think the easiest way, and suitable for most themes, is something like this in the preprocess:
And some jQuery script to remove/switch class on a click over ^show-comment
My €.02
Comment #12
realityloopI'm planning to investigate collapsing eventually, look at http://groups.drupal.org/node/65763
Re-rolled patch with Coder review stripped out and comment.tpl.php based on default from /modules/comment is attached.
Comment #13
realityloopstatus
Comment #14
marvil07 CreditAttribution: marvil07 commentedThanks for the quick response :-)
Some suggestions:
- Insert the logic about marking as dimmed in the preprocess function(
vud_comment_preprocess_comment()
)- use
vud-comment-dimmed
as the class to identify it.- IMHO this hunk is not necessary:
.. since the real use of the class is by printing on comment.tpl.php
- vud.module is not modified, avoid that hunk too
- make dim feature optional, by setting a flag in vud_comment configuration page.
Comment #15
realityloopAdded instructions to INSTALL.txt for adding required code to any theme's comment.tpl.php
Note: I posted this before previous comment was visible.. working on it..
Comment #16
realityloopTrying to get preprocess suggestion implemented but not sure I'm doing it right, could you give me some assistance?
Comment #17
realityloop-Dimming now optional by leaving field blank or setting to 0
-Improved settings form description
-Redundant code removed
-Class name changed.
I still need assistance with implementing 'vud_comment_preprocess_comment()' though, see vud_comment.module line 107 after applying this patch.
Comment #18
realityloopBump
Comment #19
realityloop-implemented 'vud_comment_preprocess_comment()' as requested in #14
-removed need to edit comment.tpl.php
-updated INSTALL.txt due to removal of comment.tpl.php
*thanks davereid for setting me on the right path*
Comment #20
gausarts CreditAttribution: gausarts commentedSubscribing. Thanks
Comment #21
realityloopHi Gaus,
Could you perhaps test the patch and mark it RTBC if you think it works fine?
Cheers,
Brian
Comment #22
gausarts CreditAttribution: gausarts commentedHi,
I love fun stuff, so I played around with it happily, and here is the results in my test bed:
1. I wanted to have great control on placing the widget, so I simply disable "Node type" selection and put the widget anywhere in the comment.tpl. This prevents double widgets. Setting -1 to trigger dimmed comment. And it FAILS to work.
2. I tried to go the regular placement by enabling one of the node types, it indeed WORKS.
So my expectation for improvement, can you possibly make the dim independent from "node type" selection, so it can also work when the widget is pulled apart from $comment object? The reason is the widget is working outside the $comment, so the dim hopefully can also work outside $comment object.
Thanks for a very sweet additional feature.
Comment #23
realityloop#22
I don't quite follow what your describing, could you try describing it another way please?
Comment #24
lut4rp CreditAttribution: lut4rp commentedI have exams right now, but I'll take some time out today (hopefully) and do a review.
Comment #25
gausarts CreditAttribution: gausarts commentedOk, sorry for not being clear.
I have two ways to display the vud widget, and notice that dim only works with way #2:
1. Anywhere. I can only do this if I DISABLE "node type" option at admin/settings/voteupdown/comment. This is to prevent the appearance of two widgets within comment.tpl (one default widget contained by $comment and another by my custom placement).
2. Default. As is contained by $comment, and I have to enable "node type" option at admin/settings/voteupdown/comment
So this dim functionality will be great if only works with way #1 as well.
Thanks.
Comment #26
gausarts CreditAttribution: gausarts commentedI know this is not the right solution, since this is hard-coded to my specific need, but works when my widget is placed anywhere outside $comment:
So I'll wait for your patches to get into the module.
Thanks
Comment #27
marvil07 CreditAttribution: marvil07 commentedRe #25: "two widgets displayed" seems to be unrelated, please take a look at How to display voting widget by API? (I think the error is just because you are disabling votes for that type).
Thanks for the changes realityloop!
Finally I going to review this today in some hours :-p at a local user meeting! .. sorry for the delay but, like Pratul, I have one exam today.
In the other hand, make this generic to other entities(nodes and terms) sounds pretty good, but not sure how to do that, so let's see what I can do in the afternoon.
Comment #28
realityloopthanks,good luck with your exams!
Comment #29
marvil07 CreditAttribution: marvil07 commentedOk, finally I could review this :-)
I've seen some notices in various places and I decided to use dependent from ctools ;-) (BTW ctools is great!)
So, I have a new patch that:
vud_widget_proxy
is for all types)In the other hand, I think dim really applies naturally only for comments, so that's the reason I did not try a more general approach.
about using collapsible divs, IMO it would be great to have that, but I think it should be in another issue, so feel free to create it
Please take a look at this patch, I hope we can commit this soon ;-)
Comment #30
realityloop#29 works fine here
Comment #31
gausarts CreditAttribution: gausarts commented#29 works like a charm with custom widget placement,
and plus +1 for cTools. ThanksUPDATE: I should rephrase it correctly, since cTools is already in 6.2*, that additional cTools setting is a real plus. I am learning much :)
Comment #32
gregglesI think this issue should really focus on comments only. If people want to add it to nodes or other objects (I can see cases where it makes sense) then that could be another issue.
Once we get this committed the question becomes, when can we roll out 6.x-2.x-dev to groups.drupal.org :)
Comment #33
marvil07 CreditAttribution: marvil07 commentedcommitted.
About g.d.o, mayb eis better to wait until a beta since I marked some issues as release blockers today :-p (aka finally I could read the whole queue)