Star Rating Rendering, Part 2: Results

Active rating blocks can be also set to display only results and prevent voting. This is read only state and it can be set by setting read only state or by setting the parameter in shortcode or function. But, for more complex rendering there are many different methods.

Rating Widgets

Star Rating widget can be used to display post ratings results with many, many options to set. Template for this type of rendering supports many different tags and there are many settings that can determine what results will be displayed. The base of the widget is template with 3 elements: header, item and footer. Default templates use lists, so the header is the list start, footer is list end, and item is list element. Table or div can be used also, it all depends on the HTML markup you want to implement.

Widget Results
Widget Results

On the image on the left you see rendered results. Each row is a one of the results elements. Each element is using several tags to show custom image, rating stars, rating value, name of the post and number of votes. There are many different elements you can use also.

Basically, if you want to make fully custom template for widget, you need to make HTML markup first that will have similar structure. One item is one rating result. Header and footer can contain anything you want. Once you have sample markup, split it into 3 elements, and you get your template. Item is repetitive, header and footer are not.

Same system for rendering is used for comments rating widget. Here are the templates used for these widgets:

  • Post rating widgets: Widget Star Rating [WSR]
  • Comments rating widget: Widget Comments Rating [WCR]
  • Blog rating widget: Widget Blog Rating [WBR]

Rating Results

For results that are meant to be in the post or anywhere else in the theme, there is separate template. But this template has absolutely the same structure and is used the same as widget template. The only difference is that default template is in form of table not list.

  • Rating result template: Standard Ratings Results [SRR]

Some of the aspects of the rendering will be changed in GD Star Rating 2.0, and some will be removed because they are duplicating some of the features. Important thing to know is that templates are HTML and nothing more. The data that will be rendered by the plugin is in form of simple percentage tags. And the best thing is that you can change template and you change rendering without modification to the theme or anything like that.


Leave a Reply