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;

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:04:13
Script start
Timing: Jan 18 2025 19:04:13
Module start 'layout'
Timing: Jan 18 2025 19:04:13
Module start 'content'
Timing: Jan 18 2025 19:04:14
Module end 'content'
Timing: Jan 18 2025 19:04:14
Script end

Main resources:

Total runtime1.0061 sec
Peak memory usage4,096.0000 KB
Database Queries63

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0115 588.0469152.6406
Module start 'layout' 0.01150.0043 740.687539.4766
Module start 'content' 0.01590.9887 780.1641562.4063
Module end 'content' 1.00450.0015 1,342.570312.1250
Script end 1.0060  1,354.6953 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00370.3641160.0002
Check MTime0.00160.1575160.0001
Mysql Total
Database connection0.00290.284010.0029
Mysqli_queries0.943493.7716630.0150
Looping result0.00070.0705610.0000
Template Total0.964395.820.4822
Template load0.00240.234320.0012
Template processing0.961995.613420.4810
Template load and register function0.00010.013310.0001
states
state_id_array0.00220.216710.0022
state_identifier_array0.00180.178520.0009
Override
Cache load0.00180.1825270.0001
Sytem overhead
Fetch class attribute can translate value0.00070.073720.0004
Fetch class attribute name0.00160.158860.0003
XML
Image XML parsing0.00070.069120.0003
class_abstraction
Instantiating content class attribute0.00000.001670.0000
General
dbfile0.00080.0769180.0000
String conversion0.00000.000940.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
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 21
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs