
string getStarsFromNum ( float $numeric_rating )
The function Data::getStarsFromNum() returns standard
star review icons for use in SearchMonkey presentation applications. You
can use star review icons to create more visually attractive ratings and
reviews. The actual return value is a template string, which Yahoo!
Search interprets and renders as an icon.
getStarsFromNum() only operates for certain presentation application components:
key/value pairs, infobar summaries, and infobar blobs
(['dict'][),
n]['name']['infobar']['summary'] and
['infobar']['blob']).
To retrieve star review icons using a string path rather than a
numeric value, refer to Data::getStars(). To retrieve
any SearchMonkey icon, refer to Data::getImage().
numeric_rating — A numeric rating between 0 and
5. For example,
Data::getStarsFromNum(4.5);
converts this numeric value to the appropriate star review
icon,
.
SearchMonkey rounds numeric_rating to the nearest
half-integer between 0 and 5. If numeric_rating falls
outside the range 0 ... 5, you must scale it to fall within this
range, or the function returns an invalid template string.
A template string designed to be consumed by Yahoo! Search. When
the presentation application renders on the search results page,
Yahoo! Search resolves the string into an <img>
element with the correct src for the specified
icon.
If you specify a numeric rating that lies outside 0 and 5, the
function still returns a template string, but Yahoo! Search displays
this invalid template string directly instead of resolving it into an
icon <img> element.