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

phantom21’s picture

I 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.

ericduran’s picture

Category: feature » bug

Yea, 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.

Fidelix’s picture

Status: Active » Needs review
StatusFileSize
new4.15 KB
new16.11 KB

The attached patch implements this functionality.
It applies against 7.x-2.x.

Label Settings

Please review.

Status: Needs review » Needs work

The last submitted patch, star_labels.patch, failed testing.

Fidelix’s picture

Status: Needs work » Needs review
StatusFileSize
new4.03 KB

I forgot a dpm() in there....

Status: Needs review » Needs work

The last submitted patch, star_labels2.patch, failed testing.

Fidelix’s picture

Version: 7.x-2.0-alpha1 » 7.x-2.x-dev
StatusFileSize
new3.76 KB

A cleaner patch.

Fidelix’s picture

StatusFileSize
new3.76 KB

Even cleaner.

ericduran’s picture

Status: Needs work » Needs review

For the test not.

Ghostthinker’s picture

Status: Needs review » Needs work
StatusFileSize
new7.15 KB

Does 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.

Ghostthinker’s picture

Status: Needs work » Needs review

Sorry, don't know exactly how to get this tested

Fidelix’s picture

There's a typo on the last lines of your patch:

+ 'labels' => (!empty($instance['settings']['lables'])) ? $instance['settings']['lables'] : array(),

succinct’s picture

This works great after fixing the typo. Any chance of getting this committed?

ericduran’s picture

Sure, :) 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 :)

Ghostthinker’s picture

StatusFileSize
new7.32 KB

Here you go

Status: Needs review » Needs work

The last submitted patch, fivestar-labels-1342864-10-notypo.patch, failed testing.

Fidelix’s picture

Status: Needs work » Needs review

Any news on this?

ericduran’s picture

ericduran’s picture

#10: fivestar-labels-1342864-10.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, fivestar-labels-1342864-10-notypo.patch, failed testing.

ericduran’s picture

The last patch needs to be re-rolled. If a patch is uploaded with the test, I have no problems committing it.

Fidelix’s picture

Status: Needs work » Needs review
StatusFileSize
new5.31 KB

I 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.

Fidelix’s picture

@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.

ericduran’s picture

Hmm, 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.

Fidelix’s picture

Any news here, Eric?

Thanks.

cafuego’s picture

Ping? :-)

hitfactory’s picture

StatusFileSize
new7.54 KB

Here's the patch from #10 re-rolled.

Fidelix’s picture

#22: fivestar-labels-1342864-22.patch queued for re-testing.

matt.rad’s picture

+ 1

darrell_ulm’s picture

fyi: Patch from https://drupal.org/node/1342864#comment-7744043 does not seem to work with fields when Display_Suite enabled.

whiteph’s picture

Issue summary: View changes
Status: Needs review » Needs work

Status 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.

GuyB’s picture

The patch in #27 worked for me (thanks!). I'm not using Display Suite tho.

Fidelix’s picture

Status: Needs work » Needs review
StatusFileSize
new5.94 KB

Another reroll for more recent dev version.

Status: Needs review » Needs work

The last submitted patch, 33: fivestar-labels-1342864-33.patch, failed testing.

Fidelix’s picture

Status: Needs work » Needs review

This one should pass...

Fidelix’s picture

StatusFileSize
new5.95 KB
thegreatone’s picture

Is there any news on this...been a while since the last update.

dbt102’s picture

+1 bump