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.
Problem/Motivation
There is no way to know what option picked the visitor when displaying thumbs up/down
Proposed resolution
Load the visitors vote and add the bundle in the "has_voted" instead of TRUE so we can set it active in the template preprocess.
Comment | File | Size | Author |
---|---|---|---|
#14 | rate-2880351-13.patch | 9.59 KB | jhuhta |
| |||
#13 | interdiff_11-13.txt | 2.27 KB | jhuhta |
#11 | rate-2880351-11.patch | 6.8 KB | Krzysztof Domański |
| |||
#11 | interdiff-10-11.txt | 6.41 KB | Krzysztof Domański |
#10 | 2880351-10.patch | 3.61 KB | rpayanm |
|
Comments
Comment #2
Maune CreditAttribution: Maune commentedHere is a patch to solve this issue.
Comment #3
Maune CreditAttribution: Maune commentedHere is a patch to solve this issue.
Comment #4
Maune CreditAttribution: Maune commentedComment #5
Maune CreditAttribution: Maune commentedComment #7
jhuhta CreditAttribution: jhuhta commentedIf I got it right, the patch #3 was supposed to add an 'active' class to the selected option (up or down). However, it didn't quite do it: it was comparing a local $vote_type ('up' or 'down') to a bundle name ('updown'), which was never true.
I rerolled the patch against current dev, enhanced it a bit to cover also yes/no vote and fixed the problem I mentioned. Now it works for me at least.
So now it saves to $has_voted the value of a vote (1/-1), not its bundle.
Comment #8
Krzysztof DomańskiComment #9
Krzysztof DomańskiComment #10
rpayanmComment #11
Krzysztof Domański1. Let's leave the property 'has_voted' unchanged. Let's add a new one 'user_voted'.
2. I changed the name of the 'active' class to 'rate-voted'.
3. I changed the css for the 'Thumbs Up / Down' widget.
Comment #12
Krzysztof DomańskiComment #13
jhuhta CreditAttribution: jhuhta commented#11 works and looks good and I could've RTBC'd it, but instead added the missing comment lines to the twig templates.
Comment #14
jhuhta CreditAttribution: jhuhta commentedSorry, the #13 patch file was left out.
Comment #15
Krzysztof DomańskiLGTM
Comment #17
Krzysztof DomańskiThanks!