Forums / Developer / star rating

star rating

Author Message

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.

eZ debug

Timing: Jan 18 2025 16:22:43
Script start
Timing: Jan 18 2025 16:22:43
Module start 'content'
Timing: Jan 18 2025 16:22:44
Module end 'content'
Timing: Jan 18 2025 16:22:44
Script end

Main resources:

Total runtime0.8564 sec
Peak memory usage4,096.0000 KB
Database Queries47

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0076 588.6563180.8516
Module start 'content' 0.00760.8446 769.5078477.7578
Module end 'content' 0.85220.0041 1,247.265642.1484
Script end 0.8563  1,289.4141 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.3877140.0002
Check MTime0.00140.1674140.0001
Mysql Total
Database connection0.00090.106010.0009
Mysqli_queries0.820995.8612470.0175
Looping result0.00040.0459450.0000
Template Total0.822296.020.4111
Template load0.00230.265220.0011
Template processing0.819995.741520.4099
Template load and register function0.00010.009210.0001
states
state_id_array0.00120.143010.0012
state_identifier_array0.00130.148920.0006
Override
Cache load0.00190.216370.0003
Sytem overhead
Fetch class attribute can translate value0.00050.058710.0005
Fetch class attribute name0.00060.074620.0003
XML
Image XML parsing0.00040.042010.0004
class_abstraction
Instantiating content class attribute0.00000.000820.0000
General
dbfile0.00110.1290180.0001
String conversion0.00000.000730.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 7
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs