use datatype star rating for votes

Author Message

Eric Tshiunza

Thursday 23 April 2009 2:10:14 am

how I can replace the results that are obtained by numbers of images and retrieve the number of people who voted.

{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}
<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>

{/for}
{/if}
</ul>

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}

 

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 19:33:23
Script start
Timing: Jan 18 2025 19:33:23
Module start 'layout'
Timing: Jan 18 2025 19:33:23
Module start 'content'
Timing: Jan 18 2025 19:33:24
Module end 'content'
Timing: Jan 18 2025 19:33:24
Script end

Main resources:

Total runtime0.5900 sec
Peak memory usage4,096.0000 KB
Database Queries46

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0062 589.0547152.6250
Module start 'layout' 0.00620.0033 741.679739.4609
Module start 'content' 0.00950.5793 781.1406408.3828
Module end 'content' 0.58880.0012 1,189.52348.1563
Script end 0.5900  1,197.6797 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.5429160.0002
Check MTime0.00130.2166160.0001
Mysql Total
Database connection0.00110.192010.0011
Mysqli_queries0.555994.2232460.0121
Looping result0.00040.0752440.0000
Template Total0.559194.820.2795
Template load0.00200.343120.0010
Template processing0.557194.413720.2785
Template load and register function0.00020.031810.0002
states
state_id_array0.00100.170310.0010
state_identifier_array0.00130.225120.0007
Override
Cache load0.00160.276450.0003
Sytem overhead
Fetch class attribute can translate value0.00090.151910.0009
Fetch class attribute name0.00080.143710.0008
XML
Image XML parsing0.00010.020710.0001
class_abstraction
Instantiating content class attribute0.00000.001310.0000
General
dbfile0.00060.0937100.0001
String conversion0.00000.001940.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/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.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
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 5
 Number of unique templates used: 5

Time used to render debug report: 0.0001 secs