doublesecretagency / craft-starratings

Star Ratings plugin for Craft CMS
Other
4 stars 3 forks source link

Impossible to invoke a method ("stars") on a string variable ("5"). #9

Closed Chalkin closed 5 years ago

Chalkin commented 5 years ago

When I try to display the rating on CraftCMS 3 (Twig Template) I always get: Impossible to invoke a method ("stars") on a string variable ("5"). Version: "version": "2.1.1",

My template Code: {{ entry.recipeRating.stars(entry.id) }}

lindseydiloreto commented 5 years ago

Looks like you're mixing up the different ways to output stars. There are actually two different ways to handle stars (depending on the needs of your project).

If you're handling stars the default way, it should look something like this...

{{ craft.starRatings.stars(entry.id) }}

If you're handling stars as a field type, it should look something like this...

{{ craft.starRatings.lockedStars(entry.recipeRating) }}

Hope that helps!

Chalkin commented 5 years ago

Yes, that helped. Thank you