I would like to modify the labels for each star so that I can have different values on specific node types; for example, I have a "goals" type that should read "Strongly Disagree" instead of "Give it 1/5."
This functionality was previously available, but can no longer be specified, even when using hook_form_alter(). I found a workaround in the fivestar_expand() function.
Old:
$options[$this_value] = t('Give it @star/@count', array('@star' => $i, '@count' => $element['#stars']));
New:
$options[$this_value] = !empty($settings['labels'][$i]) ?
t(filter_xss_admin($settings['labels'][$i])) :
t('Give it @star/@count', array('@star' => $i, '@count' => $element['#stars']));
This is my first time submitting a Drupal request, so my apologies if I'm missing something. I did look around for any possible solution and came up empty!
Comments
Comment #1
phantom21 commentedI too would like to use custom star labels. It would be nice to be able to configure the custom labels for each star in the Fivestar configuration screens.
Comment #2
ericduran commentedYea, we put this pretty deep in there. I'll mark this a bug being that is a regression and we didn't do it purpose. Just got lost in the shuffle.
Comment #3
Fidelix commentedThe attached patch implements this functionality.
It applies against 7.x-2.x.
Please review.
Comment #5
Fidelix commentedI forgot a dpm() in there....
Comment #7
Fidelix commentedA cleaner patch.
Comment #8
Fidelix commentedEven cleaner.
Comment #9
ericduran commentedFor the test not.
Comment #10
Ghostthinker commentedDoes not work for me. The settings are not stored and it does not work for fivestars in editmode. Here is my patch that works for me.
Comment #11
Ghostthinker commentedSorry, don't know exactly how to get this tested
Comment #12
Fidelix commentedThere's a typo on the last lines of your patch:
+ 'labels' => (!empty($instance['settings']['lables'])) ? $instance['settings']['lables'] : array(),Comment #13
succinct commentedThis works great after fixing the typo. Any chance of getting this committed?
Comment #14
ericduran commentedSure, :) Does someone want to upload a patch with the fix.
Also if you make and issue as Review and Tested by the community it attracts my attention easier :)
Comment #15
Ghostthinker commentedHere you go
Comment #17
Fidelix commentedAny news on this?
Comment #18
ericduran commented#15: fivestar-labels-1342864-10-notypo.patch queued for re-testing.
Comment #19
ericduran commented#10: fivestar-labels-1342864-10.patch queued for re-testing.
Comment #21
ericduran commentedThe last patch needs to be re-rolled. If a patch is uploaded with the test, I have no problems committing it.
Comment #22
Fidelix commentedI made some changes to the code so it complies with the coding standards and fixed the typos.
It applies to the current git code. Let's see if it passes the tests.
Comment #23
Fidelix commented@ericduran, do you prefer that the label settings are defined on the formatter settings form, or on the field settings form (like Ghostthinker did)?
I discovered what went wrong with the patch at #8, and I'm confident that I can fix it if you believe it is the best approach.
Comment #24
ericduran commentedHmm, good question. At 1st the formatter settings seems correct. But honestly this probably belongs in the field setting. Also we need to make sure it works for both fields.
I'm going to think about this a bit more.
Comment #25
Fidelix commentedAny news here, Eric?
Thanks.
Comment #26
cafuego commentedPing? :-)
Comment #27
hitfactory commentedHere's the patch from #10 re-rolled.
Comment #28
Fidelix commented#22: fivestar-labels-1342864-22.patch queued for re-testing.
Comment #29
matt.rad commented+ 1
Comment #30
darrell_ulm commentedfyi: Patch from https://drupal.org/node/1342864#comment-7744043 does not seem to work with fields when Display_Suite enabled.
Comment #31
whiteph commentedStatus was "Needs Review", yet there are two patches and according to #30 the patch in #27 has an issue when Display_Suite enabled.
Which patch should be committed?
Do both have an issue with Display_Suite? If so, would it be better to install anyway, so that sites without Display_Suite enabled can use custom labels? Then we can re-work the patch to work with Display_Suite later.
If someone other than a patch author can confirm that it works, please set status to RTBC and I'll look at committing it.
Comment #32
GuyB commentedThe patch in #27 worked for me (thanks!). I'm not using Display Suite tho.
Comment #33
Fidelix commentedAnother reroll for more recent dev version.
Comment #35
Fidelix commentedThis one should pass...
Comment #36
Fidelix commentedComment #37
thegreatone commentedIs there any news on this...been a while since the last update.
Comment #38
dbt102 commented+1 bump