The Rating helper contains some useful rating-related functions that aren’t covered in the Rating form helper.

Loading the Helper

$rh = Loader::helper(‘rating’);

Methods

$html = $rh->outputDisplay($value);

When given a numeric $value, outputs a ratings display for the given value. $value is typically the numeric value stored by a rating input element.

$html = $rh->outputAverage($field, $value)

Outputs a rounded average (so allows the usage of half-stars.) Useful when working with the getAverageChildRating function.

$avg = $rh->getAverageChildRating($cItem, $akHandle)

Gets the average of all child pages of $cItem, where $cItem can either be a page ID or page object. $akHandle is the handle of the relevant rating attribute to be checked.

$rh->outputAverageChildRating($cItem, $akHandle, $fieldOverride = false)

Combines getAverageChildRating and outputAverage and prints out the average rating.

Recent Discussions on this Topic

Helper:Ratings Documentation error

http://www.concrete5.org/documentation/developers/helpers/ratings The example loading method contains a plural "s" $rh = Loader::helper('ratings'); But [in the current version at least (5.4.1.1)] it needs to be singular: $rh = Loader::helper('…

Ratings: Half Stars and Custom Stars

So I implemented my own custom stars, and it's fine and dandy when I use $rh->outputDisplay(90); but when I tried $rh->outputAverage('', 90), it messes up a bunch of the other stars on the page (see screenshots attached). The one that looks good (4.5 s…