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.
With hook_fivestar_widgets(), you can add different star display styles to the available list. But you can't remove or rename the existing ones.
This patch adds a hook_fivestar_widgets_alter() to allow other modules to completely control the types of stars that users can choose from.
Comment | File | Size | Author |
---|---|---|---|
#18 | 1249398-18-hook-fivestar-widgets-alter.patch | 5.31 KB | TR |
| |||
#17 | interdiff-10-17.txt | 2.49 KB | TR |
#17 | 1249398-17-hook-fivestar-widgets-alter.patch | 5.3 KB | TR |
| |||
#10 | 1249398-10-hook-fivestar-widgets-alter.patch | 2.76 KB | TR |
|
Comments
Comment #1
David_Rothstein CreditAttribution: David_Rothstein commentedOh, I forgot to mention: This patch is rolled on top of the patch at #547050: Widget per axis (it will only apply after that one is committed).
I did that because it looks like that will be committed soon, and it adds a bunch of module_invoke_all('fivestar_widgets') calls and such so it totally changes the code that would be necessary here.
Comment #2
David_Rothstein CreditAttribution: David_Rothstein commentedHm, reviewing my own patch... it looks like it will definitely allow options to be removed, but things get complicated when renaming options, since the module uses strtolower() in some places to go between the human-readable and machine-readable name.
That may also mean that the patch's inclusion of t('Default') in hook_fivestar_widgets() is problematic too (will cause problems in other languages).
I think to fix this properly and make it fully alterable we'd actually need to clean up the associated code and change the array structure of hook_fivestar_widgets() itself so it separates the human and machine names, something like:
Would that make sense?
Comment #3
ericduran CreditAttribution: ericduran commentedMakes sense indeed. Uhm I'm ok with rolling it with this patch, or we can open a separate issue.
Comment #4
ericduran CreditAttribution: ericduran commentedMoving this up.
Comment #5
ericduran CreditAttribution: ericduran commentedtagging
Comment #6
Kristen Pol#2 would be nice. I tried to use "Big Stars" and the css ended up like "foo.big stars".
Comment #7
whiteph CreditAttribution: whiteph commentedMoved the priority down. Using the definitions in Priority levels of issues, where it says Tasks and Feature Requests are very rarely “critical”. They should usually be “normal” or “minor”.
The patch really does need re-work as it no longer successfully applies, even with a 3-way merge. And there's still the question of the "Default".
Comment #8
TR CreditAttribution: TR commentedNot in D7 at this point in time, but I think this is a good idea for D8.
Comment #9
TR CreditAttribution: TR commentedThis should be easy to do now that #3136366: hook_fivestar_widgets() implementations should explicitly include their associated libraries has been committed.
Comment #10
TR CreditAttribution: TR commentedThis patch adds hook_fivestar_widgets_alter() for D8 and provides a test implementation and a test case.
Comment #11
init90Looks totally good! One thing that left is documentation about the hook in
fivestar.api.php
Comment #12
pavnish CreditAttribution: pavnish at Srijan | A Material+ Company for Drupal India Association commented+ protected function setUp(): void {
setUp function should type hunt with void.
Comment #13
pavnish CreditAttribution: pavnish at Srijan | A Material+ Company for Drupal India Association commentedPlease review this patch for #12
Comment #14
pavnish CreditAttribution: pavnish at Srijan | A Material+ Company for Drupal India Association commented#11 still need to be work
Comment #15
TR CreditAttribution: TR commented@pavnish: No, we're not adding return type declarations or static type hinting now, certainly not as part of this issue. If you want to tackle just the return type declarations for the ENTIRE Fivestar code base then please open a new issue and supply a patch - when this is done it will all be done together.
#3050720: [Meta] Implement strict typing in existing code
Comment #16
pavnish CreditAttribution: pavnish at Srijan | A Material+ Company for Drupal India Association commented@TR Thanks for suggestion we will create a new issue for that once this is done .As of now Please ignore #12 #13
Comment #17
TR CreditAttribution: TR commentedHere is patch #10 with the additions to fivestar.api.php mentioned in #11.
Comment #18
TR CreditAttribution: TR commentedLet's see if we can get rid of the CS message.
Comment #19
init90Thanks! Looks good for me.
Comment #21
TR CreditAttribution: TR commentedCommitted.