Displays a Rating plugin. The plugin presents the average rating of an item and a link to show all the reviews.
Plugin's Default Design
The following screen shot presents a Rating plugin:
The design is fully customizable via HTML Elements Style (CSS).
The following table lists the available parameters:
|||containerID||string||An ID of a <div> element on the page in which you want to display the plugin.|
|||categoryID||integer||The identifier of the Comments Category with which this plugin is associated.|
Before embedding a Rating plugin in your site, you are required to create at least one Comments Category in the Comments Setup page on Gigya's website, and assign to it 'Operation mode: Rating & Reviews'. When creating a new Comments Category, a unique categoryID is created. The generated 'Embed code' includes the categoryID. You can use this code to embed the plugin in your site.
|||streamID||string||In each category you may define multiple streams. Set this parameter with a unique ID of your choice to identify a stream. Note: the string is limited to 150 characters and is case sensitive.|
|||actionAttributes||JSON object||In Gamification your users receive points for actions they perform on your site, in this case adding a rating grants the user points. Action Attributes may be used to annotate actions with additional information, such as the section of the web site that generated the action. If you set here the actionAttributes, each time a user adds a rating, the action also receives an attribute, for example "tv-show":"glee", which can mean that the action was performed on the "Glee" page of the site. |
actionAttributes contain a JSON object comprised of a series of attribute keys (categories) with associated values. You can also use a generic "tags" key.
No more than three values can be given, they can be with a single key or each have their own key.
For more information see Variants and Action Attributes. Action attributes are later used to filter GM Plugins by a certain attribute.
|||context||object||A reference to a developer created object that will be passed back unchanged to the event handlers as one of the fields of the eventObj (see extended explanation in the "Plugin Events" section below).|
|||linkedCommentsUI||string||The containerID ( <div> ID) of a Comments plugin that resides on the same page. This will be used to jump to the appropriate section in the comments plugin when the user clicks the # reviews link or the "Write your review" button.|
|||ratingTemplate||string (HTML)||Using this parameter you may override the default design of the Rating plugin. Defines an HTML template representing the design of the Rating plugin. The HTML template supports the following placeholders: $stars, $readReviewsLink, $addReviewButton, $write_a_review and $review_summary. |
There is also a new template format, which uses HTML classes instead of the $ placeholders:
|||showCommentButton||Boolean||Indicates whether the "Write your review" button is displayed in the plugin. The default value is 'true'.|
|||showReadReviewsLink||Boolean||Indicates whether the "Read reviews" link is displayed in the plugin. The default value is 'true'.|
|||useHiResIcons||Boolean||Default: 'false', uses standard icons. When 'true' icon resolution will be set by the device's pixel ratio. Recommended for mobile displays, for example iPhones with retina display. |
Note: If Gigya's icons are overridden by custom icons and this parameter is set to 'true', it may cause display problems.
|||width||integer||Determines the width in pixels of the plugin. The minimum width is 493 pixels before wrapping, 205 pixels after wrapping. Width can also be specified in percentages of the container element: "100%" , "50%" etc.|
|Events Registration Parameters|
|||onLoad||function ref||A reference to an event handler function that will be called when the plugin has finished drawing itself.|
|||onError||function ref||A reference to an event handler function that will be called when an error occurs.|
|||onAddReviewClicked||function ref||A reference to an event handler function that will be called when the "Write your review" button clicks.|
|||onReadReviewsClicked||function ref||A reference to an event handler function that will be called when the # reviews link clicks.|
The single argument, eventObj, contains information about the event and has different fields for different events.
The following tables specify the list of fields available in the eventObj for each event:
onLoad Event Data
onError Event Data
|errorCode||integer||The result code of the operation. Code '0' indicates success, any other number indicates failure. For a complete list of error codes, see the Error Codes table.|
|errorMessage||string||A short textual description of an error, associated with the errorCode, for logging purposes.|
|errorDetails||string||This field will contain the exception info, if available.|
Please refer to Events to learn more about how to handle events generated by the Gigya service.
In the Rating & Reviews demo you will find a complete working example that uses the comments.showRatingUI method. You may view the code, run it and view the outcome.