Forums / Developer / use datatype star rating for votes

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}

 

eZ debug

Timing: Jan 31 2025 04:27:18
Script start
Timing: Jan 31 2025 04:27:18
Module start 'content'
Timing: Jan 31 2025 04:27:18
Module end 'content'
Timing: Jan 31 2025 04:27:18
Script end

Main resources:

Total runtime0.4172 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 587.9531180.8281
Module start 'content' 0.00540.0147 768.781393.8047
Module end 'content' 0.02010.3970 862.5859523.7969
Script end 0.4171  1,386.3828 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.8961200.0002
Check MTime0.00150.3598200.0001
Mysql Total
Database connection0.00060.141710.0006
Mysqli_queries0.331479.44091410.0024
Looping result0.00160.37391390.0000
Template Total0.396595.010.3965
Template load0.00080.198510.0008
Template processing0.395794.849310.3957
Override
Cache load0.00060.144310.0006
Sytem overhead
Fetch class attribute can translate value0.00050.128710.0005
XML
Image XML parsing0.00030.060410.0003
General
dbfile0.03648.7367200.0018
String conversion0.00000.001430.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs