Forums / Developer / star rating
Bienvenu Isaac Kanyinda
Wednesday 22 April 2009 7:37:03 am
use datatype star rating of how to replace the result by the numbers of images. where there are 2 / 5 that we can have 2 images of different colors than the other 3
{def $rating=$attribute.content $rating_url=concat('/starrating/collect/',$attribute.id,'/',$attribute.version,'/')} <ul class="star-rating"> <li id="rating_percent_{$attribute.id}" class="current-rating" style="width:{$rating.rounded_average|div(5)|mul(100)}%;">Currently {$rating.rounded_average|wash}/5 Stars.</li> {if $rating.has_rated|not} {for 1 to 5 as $num} {if $var|eq('o')} <li></li> {else} <li><a href={concat($rating_url,$num)|ezurl} id="sr_{$attribute.id}_{$num}" title="Rate {$num} stars out of 5" class="stars-{$num}" rel="nofollow" onfocus="this.blur();">{$num}</a></li> {/if} {/for} {/if} </ul> {literal} <script type="text/javascript"> var tsh = document.getElementById("rien");{/literal} tsh.innerHTML={$rating.number} {literal} var etoile = document.getElementById("tv_moyenne");{/literal} etoile.innerHTML={$rating.rounded_average|wash} </script> {*Rating: <strong><span id="average_{$attribute.id}">{$rating.rounded_average|wash}</span></strong>/5 (<span id="total_{$attribute.id}">{$rating.number|wash}</span> votes cast) <p id="has_rated_{$attribute.id}">{if $rating.has_rated}Thank you for your rating!{/if}</p>*} {if $rating.has_rated|not} {def $hasXajaxAccess=fetch('user','has_access_to',hash('module','xajax','function','all'))} {if $hasXajaxAccess}{run-once}{xajax_javascript()}{/run-once}{/if} {run-once}{xajax_javascript()}{/run-once} <script type="text/javascript"> function starrating_init_{$attribute.id}() {ldelim} {for 1 to 5 as $num} YAHOO.util.Event.addListener("sr_{$attribute.id}_{$num}", "click", function(e){ldelim} YAHOO.util.Event.preventDefault(e); xajax_starrating({$attribute.id}, {$attribute.version}, {$num}); {rdelim}); {/for} {rdelim} YAHOO.util.Event.onDOMReady(starrating_init_{$attribute.id}); function starrating_clear_{$attribute.id}() {ldelim} {for 1 to 5 as $num} YAHOO.util.Event.removeListener("sr_{$attribute.id}_{$num}", "click"); {/for} {rdelim} </script> {/if}
Petit poisson deviendra grand pourvu que Dieu lui prête vie. Petit oiseau volera un jour de ses propres ailes pourvu que Dieu lui ajoute le nombre de jours sur terre.