With ratings API you can generate links or buttons, depending on the classes that you are using, that will allow users to rate an item. It can be used only with the like button or it can be used with the dislike button.
API example
jimport('oniscore.rating'); //import ratings libraries
$ratingsHTML = onisRating::rating((int)$petition->id, 'petition', 'btn btn-xs btn-default', CCOMPONENT);
Generate the HTML code:
onisRating::rating($itemid, $item, $class = NULL, $component);
- $itemid - unique, numerical item id;
- $item - unique item name;
- $class - css classes for the button;
- $component - component name;
You can change HTML code here:
libraries/oniscore/rating.php
To show the rating for an item you can use:
onisRating::ratingLabel($rating);
- $rating - numerical rating count, can be negative;
Example:
$ratingCount =
onisRating::ratingCount((int)$petition->id, 'petition', CCOMPONENT);
$ratingLabelHTML = onisRating::ratingLabel($ratingCount);