It's line 4 of this part of fivestar.module:

$options = array('-' => t('Select rating'));
for ($i = 1; $i <= $element['#stars']; $i++) {
$this_value = ceil($i * 100/$element['#stars']);
$options[$this_value] = t('Give @title @star/@count', array('@title' => $title, '@star' => $i, '@count' => $element['#stars']));}

It creates a verbose title on every star. I tried this javascript

var elements = document.getElementsByTagName('a');

for (var i = 0, len = elements.length; i < len; i++)

but it doesn't affect these links. I even tried doing it inline at the bottom of html.tpl. Is there a function I can use in template.php? Full file if it helps.


The reason your javascript didn't work is simple. If you disable Javascript and load the page with the fivestar widget, it's just a simple <select> list. It's turned into a clickable star widget using Javascript as well. So your js was most probably being overridden by fivestar.

You can do this without hacking the module and without using javascript by creating another custom module, but there's a small issue explained at the end. Lets call the module myfivestar for example.

You would then need to implement hook_element_info_alter() to change the fivestar element's process callback to your own custom one:

function myfivestar_element_info_alter(&$type) {
  // Change the process callback of fivestar to myfivestar_expand
  if (isset($type ['fivestar']['#process'])) {
    $type ['fivestar']['#process'] = array('myfivestar_expand');

Now you just need to copy the function fivestar_expand from the fivestar.module to your own module, rename it to myfivestar_expand, and change the line:

$options[$this_value] = t('Give @title @star/@count', array('@title' => $title, '@star' => $i, '@count' => $element['#stars']));


$options[$this_value] = ''

which will effectively make the <select> list useless for visitors browsing with Javascript off as it removes the option labels which are then turned into the title attribute using fivestar's javascript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.