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.