Forums / Developer / Why this add doesn`t work in rating module ?!

Why this add doesn`t work in rating module ?!

Author Message

Marvix Marx

Wednesday 31 January 2007 12:14:40 pm

Hi ..

I had downloaded the rating extension, I just would like to add a list function for the top rated .. so in ratingoperatorresult.php i had added this :

    function ratingOperatorResult( $args )
    {
        include_once( 'lib/ezdb/classes/ezdb.php' );

		$db =& eZDB::instance();
		
		switch ( $args['function'] )
        {
            case 'total_votes':
            {
                $row = $db->arrayQuery( "SELECT count(*) as votes FROM ezarticle_rating WHERE node_id='".$args['key']."'" );
                return $row[0]['votes'];
            } break;
			// Start: Top Rated List //
            case 'top_votes':
            {
                $row = $db->arrayQuery( "SELECT *  FROM ezarticle_rating as top_votes order by top_votes.rate DESC " );
				return $row['top_votes'];
            } break;	
			// End: Top Rated List //
            case 'average_value':
            {
                $row = $db->arrayQuery( "SELECT round( sum( rate ) / count( * ) ) AS estimate
													FROM ezarticle_rating
													WHERE node_id = '".$args['key']."'" );
                return $row[0]['estimate'];
            } break;
        }
    }

I called from temapltes by :

{ratingoperatorresult(hash( 'function', 'top_votes' ) )}

but its return nothing ... the query its right ,,, why its not working ?

Thanks in advanced.

Łukasz Serwatka

Thursday 01 February 2007 12:19:50 am

Did you tell eZ Publish that your tpl operator is active? What errors do you have in debug output? Take a look here for more info about tpl operators.
http://ez.no/ezpublish/documentation/development/extensions/template_operator

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Marvix Marx

Thursday 01 February 2007 3:27:00 am

Hi ,,,


{ratingoperatorresult(hash( 'key', $key, 'function', 'total_votes' ) )} 
{ratingoperatorresult(hash( 'key', $key, 'function', 'average_value' ) )} 

this operator works fine but not working with top_votes .. its one operator with switch, so I think no need to add to operators list.

and in the debug i get no errors, in the mysql debug also no errors !

Łukasz Serwatka

Thursday 01 February 2007 4:51:05 am

Try $row[0]['top_votes']

arrayQuery returns results in array.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Marvix Marx

Thursday 01 February 2007 11:44:36 pm

Found it ...

must be :
return $row;

eZ debug

Timing: Jan 18 2025 19:33:56
Script start
Timing: Jan 18 2025 19:33:56
Module start 'content'
Timing: Jan 18 2025 19:33:56
Module end 'content'
Timing: Jan 18 2025 19:33:57
Script end

Main resources:

Total runtime0.1684 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.0081 587.8438180.8125
Module start 'content' 0.00810.0084 768.656398.0547
Module end 'content' 0.01650.1518 866.7109527.3750
Script end 0.1683  1,394.0859 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00362.1202200.0002
Check MTime0.00150.8652200.0001
Mysql Total
Database connection0.00090.524410.0009
Mysqli_queries0.118570.39111410.0008
Looping result0.00160.95071390.0000
Template Total0.151289.810.1512
Template load0.00120.704610.0012
Template processing0.150089.087210.1500
Override
Cache load0.00090.529210.0009
Sytem overhead
Fetch class attribute can translate value0.00080.487010.0008
XML
Image XML parsing0.00030.202710.0003
General
dbfile0.00160.9273200.0001
String conversion0.00000.006130.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