The stars are not outputting in my nodes. Using 'as stars', 'rating' and 'percentage' does not output any data other than the field's label.

Checking out the node's render with devel, I can see ['field_NAME']['#markup'] as just the integer (60, 80, 100), perhaps something is wrong with a theming function?

Comments

bsuttis’s picture

Some observations so far:

  • hook_field_formatter_view() uses $entity_type and $entity according to api docs. fivestar.field.inc is using $obj_type and $object instead, not sure if that's an issue
  • Within my field.tpl.php file, $items is empty -- and I don't understand why because within $element exists #items which has an array keyed as 0 with 'rating' and 'target' values. According to template_preprocess_field, $items should get data via the foreach ($element['#items'] as $delta => $item)..., no?
bsuttis’s picture

I've made some progress. I rewrote fivestar_field_formatter_view as follows, I haven't addressed the other 2 formats (rating, percentage) yet.

/**
 * Implements hook_field_formatter_view().
 */
function fivestar_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $result = array();

  switch ($display['type']) {
    case 'default':
      foreach ($items as $delta => $item) {
        $result[$delta] = array(
          '#theme' => 'fivestar_static', // theme_fivestar_static
          '#rating' => $item['rating'],
          '#target' => $item['target'],  
        );
      }
      break;
  }

  return $result;
}

Not sure if $item['target'] is necessary as the $variables in the theme function are rating, stars, and tag. No patch sorry, let me know if this is the way to proceed, ratings display as stars in nodes and views now.

ezra-g’s picture

Just a heads up, this might be related to http://drupal.org/node/786224#comment-4049938 .

ericduran’s picture

Hey,

A couple of questions, are you using the latest dev?
How are you trying to display the stars?
Are you setting up the stars for user voting? Or as a field?
Are you using views for display?

Thanks :)

davidthornley’s picture

Hi,

I am seeing this issue as well. I have tried with the latest dev snapshot. Using above patch does not help either. With this patch I nolonger see the labels for my fivestar fields.

Let me know if more information would help.

bsuttis’s picture

davidthornley, on node display (i.e. node/1) labels output for me, however they are gone on the node/1/edit. I believe a different function (theme_fivestar_widget) controls the output on node/1/edit though, the classes are different and it makes sense to me, since the stars aren't static on node edit.

ericduran,
- Latest dev as of approx the time I posted -- 7.x-2.x-dev
- Displaying the stars: at node display (node/1) and as fields in Views
- As a field, it's the Fivestar rating field that is set at node creation
- Yes, views is used

bsuttis’s picture

Can't seem to find an actual theme function that controls the widget on node edit (i.e. node/1/edit).

Seems fivestar_expand() is where it's outputting from right now. Doesn't appear to have a '#theme' override.

My fivestar.module:
// $Id: fivestar.module,v 1.42 2011/02/01 17:15:07 ericduran Exp $

The latest dev seems is be omitting that line.

ericduran’s picture

Status: Active » Closed (duplicate)

@bsuttis, Ok so you're using views to display the fivestar widget.

I'm going to closed this issue as a duplicate of http://drupal.org/node/1047664 because is a bit more clear as to what the actual issue is and is older.

Sorry for the views functionality not being ported yet. It will be completed soon but for now the widgets should be working if you use the regular displays options.

Thanks.

ericduran’s picture

Status: Closed (duplicate) » Active

woops, the views threw me off, this is it's on issue. Fixing now....

ericduran’s picture

Status: Active » Fixed

Now this issue of the fivestar field stars not being display on the node is fixed. -- http://drupal.org/commitlog/commit/2490/796b3c5609706f18b98be67d75bd5a7c...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.