Php code
print fivestar_widget_form($node);
doesn't work for drupal 7.
What string is needed to properly display the widget in d7?

Comments

brz’s picture

Status: Active » Closed (fixed)
gjones’s picture

print render(fivestar_widget_form($node));

Works for me.

jjones2008’s picture

I have tried both ways and neither work for me in drupal 7. I keep getting the error "Call to undefined function fivestar_widget_form()" Any ideas why I cannot print the fivestar widget?

brz’s picture

Now with CCK field:

<?php
	print render($content['field_vote']); 
?>

You have to create Fivestar field (in this case "vote" field).
Hi

jjones2008’s picture

@brz thank you very much! It works great for me.

rogical’s picture

Can you give some guide on how to render it on user page? I just want to render it in author pane.

thoughtcat’s picture

I've got the same problem trying to output the rating widget in a D7 site.

If I try the solution in #2 above, all styles fall off my page altogether.

If I try solution #4, the stars widget does not display at all. I have modified it to field_rate which is the name of my Fivestar field.

If I look at the available body variables in Content Templates, there doesn't seem to be any reference to the field at all. The field is not set to "hidden" in "manage fields" and the widget displays fine if I untick "affect body output".

Someone posted in a D6 issue that you could just activate a block for the page and the rating widget would display in there - is this not available for the D7 version? I can't see a relevant block in my blocks admin.

petkove’s picture

Thx! Saved me. Also some themes require drupal_render method instead of render - eg. drupal_render($content['field_rating']); <- i created a field rating of type Fivestar rating.

--
http://eurobuecher.com

thoughtcat’s picture

Changing from print render... to print drupal_render... didn't fix it for me. (I'm using Bartik)

moonshdw8’s picture

I tried all of the suggestions here (and everywhere else I could look), but nothing seemed to make the rating system appear on my custom product page. This is the one that finally did it:

<?php 
$fivestar = field_view_field('node', $node, 'field_fivestar_awesomeness');
print render($fivestar);
?>

I found the answer here: http://drupal.stackexchange.com/questions/25916/using-fivestar-get-votes...

Hope this helps someone else. It took me 2 days to find the answer.

NenadP’s picture

moonshdw8, i confirm your solution works for me both in node and in other context! I had hard time with this.
Thanks for your hard work and solution :)

Only, how do you set styling , (pass the options about widget type - type of stars etc) as it is rendered as default and not the way is set in the field on content type field page ? How do you add fivestars tags, too ?

NenadP’s picture

By intuition :) , i tried

$fivestar = field_view_field('node', $node, 'field_vote','basic');

To get the widget go with 'basic' widge type, and it worked! So you just pass an extra parameter with desired widget type!

EDIT: When i enabled "Expose this Fivestar field for voting on the @type type." it started to style te stars in those content type were field is defined.

Maybe someone has more info about those aditional parameters.

moonshdw8’s picture

Thanks HoverFusion for the extra feedback. That was something else I was having trouble with. It seems intuition is the only way i can ever figure out anything with Drupal :)

NenadP’s picture

moonshdw8 no problem!

Only thing i noticed with this approach is that it is very performance costly when i tried to load it multiple times (I have books loaded as teasers, and then i loaded fivestar for every book - but site performance was drasticaly influenced in negative way).

I am not sure if this is because of Fivestar in general or in the way i output it.

dewancodes’s picture

I tried this and it worked for me.
You just need bit of css if you want to hide field labels etc.

barick_manoranjan’s picture

Issue summary: View changes

#12 Worked...Great..
Actually I was looking for this in my node template:
$fivestar = field_view_field('node', $node, 'field_vote','oxygen');

Thank You.

feldmarv’s picture

#10 works perfectly!