Skip to main content
The eKomi product rating shows the star ratings and customer comments for an item on the product page. This page contains the complete sample files for it: the rating template in two variants, the AJAX template, the JavaScript callback functions, and the CSS for the rating bars. All labels in the examples are sample texts. Replace them with your own or with text placeholders from the shop.config. Guide: eKomi product rating · Reference: E-PRODRATING-EKOMI tags

Overview of the files

With or without AJAX

Both variants display the same thing. The only difference is what happens when paging and when filtering by “X stars”. Choose one variant and stick with it. Mixing both results in some of the links reloading the page and others not.

The rating template

Both versions belong in the same file incl_prodrating_ekomi.htm. Use only one of them.
~E-PRODRATING-EKOMI_Count(n)~ isn’t just a display setting. This tag loads the ratings and sets up paging. If it’s missing or placed too far down, all blocks below it remain empty.So place it as the very first tag at the beginning of the template.
The AJAX version of the previous documentation contains Count twice, with 15 and with 10, and with two different comments. Since the second call overrides the first, effectively 10 ratings per page would be shown. Shortened to one call here.

Other differences between the two versions

Beyond the links, the AJAX version displays some things differently. This isn’t a requirement but a matter of taste, and you can mix both as you like.
  • The AJAX version already states the total number in the heading and writes the number of votes inside the bar instead of next to it.
  • The version without AJAX shows ~E-PRODRATING-EKOMI_PositivePercentage~ as a percentage, the AJAX version shows ~E-PRODRATING-EKOMI_PositiveVotes~ as an absolute number.
  • Without AJAX, the paging bar is above the ratings and outside {E-PRODRATING-EKOMI_FeedbackData}; with AJAX, it’s below the ratings and inside this bracketing. Inside means: without ratings, there’s no paging bar either. This is the more sensible variant.
  • Only the version without AJAX has arrows for one page forward and back, via PagingBack and PagingNext.

The AJAX template

ws_ajax_eKomi.htm is short. It only delivers the rating block, without the rest of the page framework.
The name between the angle brackets determines which container on the product page is replaced. So give the div that contains the rating the ID product_rating_ekomi.

The JavaScript callback functions

ws_AJAXloadTemplate expects four functions. Even if you don’t want to do anything in them, they must exist, otherwise the call aborts with an error.
Two of the four names begin with ws_, the other two only with ws. This is inconsistent but correct: the templates call exactly these names. If you change a name, you must also change it everywhere in the template.

The CSS for the rating bars

The trick with zero

Both templates add a second class to the row that ends with the number of votes:
With three votes, this results in rating_ekomi_graphic_line_3; with no votes, rating_ekomi_graphic_line_0. There’s a rule in the stylesheet only for zero, and it makes the text gray and the mouse pointer normal. This way, a rating level without votes no longer looks like a link. At the same time, the bracketing around the href or onclick ensures that it isn’t one either.
The templates use four additional classes that are missing from this stylesheet: clear, infobox, rating_paging_placeholder, and rating_paging_actualpage. Add them yourself, otherwise the merchant response and the paging bar appear without styling.

Where the tags are described

This page explains the sample files, not the individual tags. The complete description of all E-PRODRATING-EKOMI_ tags, with types, parameters, and the peculiarities of the paging bar, is on the reference page. Reference: E-PRODRATING-EKOMI tags Three points from there are particularly important when recreating the examples:
  • Count() belongs at the beginning of the template as the first tag. It loads the ratings and sets up paging.
  • If the numeric parameter is missing from the four paging tags, they calculate with five pages. The examples above specify 2 and 3 everywhere.
  • PagingParam automatically includes an active filter. You don’t need to append it.
Compared to the previous documentation, eight places in the listings have been corrected: a superfluous curly brace after a bracketing, an incorrectly closed loop PagingBefore(2>, the duplicate Count call in the AJAX version, a comment that referred to reloading terms and conditions instead of ratings, a character encoding error in the JavaScript, a comment stuck to the first line, a superfluous space in a class attribute, and the heading of the AJAX page, which read “without AJAX”.