nican VIP
Total posts: 392
08 Mar 2014 10:59

I am not a programmer but reading the rating API documentation I think that I've got the idea on how to set it up, the only thing I cannot understand is how to use the $condition variable.

I have a type which has another type assigned for reviews, so I disabled the parent type rating, and now on Sergey suggestion I need to use rating API to display the number of votes and/or rating html in the records list and full view.

But for what is explained in the documentation the $condition variable allow you to dispaly the rating for a certain user ID, record ID and so on...

now... how can I make this dynamic? I need one code that will work for all records of this section/type not for only one user or one record

I think I am missing the technique to dinamically call the record (or user?) ID in the records list and full templates, so that the ratng is properly displaied.

Right now if I use the code without the $condition variable in it, obviously the sum of all the records ratings is being displaied, and it's not filtered per record

I also see this error

Warning: Missing argument 3 for CobaltApi::renderRating(), called in /home/alkemica/public_html/components/com_cobalt/views/record/tmpl/default_record_operatore.php on line 301 and defined in /home/alkemica/public_html/components/com_cobalt/api.php on line 34

which I do not know if it's due to the missing $condition variable in my code, or to something else

the code I am using when I see the above error is this one

<?php $rating = CobaltApi::renderRating(15, 6);?>
<div>
    <?php echo $rating['html'] ?><br>
    Voto: <?php echo $rating['total'] ?> su 100.<br>
    <?php echo $rating['num'] ?> voti
</div>

thank you

Last Modified: 13 Mar 2014


Sergey
Total posts: 13,748
10 Mar 2014 06:14

The $condition containe WHERE condition for SQL query. For example to get rating of all articles that are comments of current article.

$rating = CobaltApi::renderRating(15, 6, "r.parent = 'com_cobalt' AND r.parent_id = " . $this->item->id);

nican VIP
Total posts: 392
10 Mar 2014 14:20

ok, I inserted this code

sorry, the editor keeps breaking the code, I attach it

rating code

now if I visit the record the code generates the rating html, but it displays no votes and I see this error message Warning: Division by zero in /home/alkemica/public_html/components/com_cobalt/api.php on line 100


nican VIP
Total posts: 392
10 Mar 2014 14:32

if insert that code in the records list tenmplate instead, then I get an error page with this message

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3 SQL=SELECT r.votes, r.votes_result, r.multirating FROM sxmb8_js_res_record AS r WHERE r.type_id = 15 AND r.section_id = 6 AND r.parent = 'com_cobalt' AND r.parent_id =

Sergey
Total posts: 13,748
10 Mar 2014 14:34

I fixed the error, and please give me the link to article with this rating.


nican VIP
Total posts: 392
10 Mar 2014 16:51

thank you

all the articles in this page http://www.alkemica.net/operatori-olistici/contenuti/6-olistico

have rating/review with children type

you may check this test record http://www.alkemica.net/operatori-olistici/voce/18-persone/78-giuseppe-verdi

whcih has some test ratings already inserted


Sergey
Total posts: 13,748
11 Mar 2014 07:51

I do not see any error on that page.

But your SQL error is due to $this->item->id. May be you have to use $item->id. I do not know wheer you use it, but you have to use ID of the record.


nican VIP
Total posts: 392
11 Mar 2014 09:12

Sergey I do not see any error on that page.

But your SQL error is due to $this->item->id. May be you have to use $item->id. I do not know wheer you use it, but you have to use ID of the record.

you weren't seeing the error because I commented out the code as that is an almost live page

I tried to insert $item->id, now I get this error int he records list view - http://www.alkemica.net/operatori-olistici/

Warning: Division by zero in /home/alkemica/public_html/components/com_cobalt/api.php on line 100

rating_in_list_error

same error in the record full view - http://www.alkemica.net/operatori-olistici/voce/18-persone/78-giuseppe-verdi (you ahve to be logged in as special user to see this last page)


nican VIP
Total posts: 392
11 Mar 2014 09:50

in the renderRating part of the code I tried to change type and section IDs

previously I had put there section and type ID of the parent type (the one whcih is being rated)

now I tried to pu there section and type ID of the child type (the one used to submit ratings)

I tried just beacuse I was not sure if that could be the cause of the error

but I still get empty ratings and the message Warning: Division by zero in /home/alkemica/public_html/components/com_cobalt/api.php on line 100


Sergey
Total posts: 13,748
12 Mar 2014 10:14

Division by 0 will be fixed in next release.


nican VIP
Total posts: 392
12 Mar 2014 10:45

ok thank you for now then


nican VIP
Total posts: 392
13 Mar 2014 09:01

I just installed cobalt 8.499 but I still see the error

/home/alkemica/public_html/components/com_cobalt/api.php on line 100

I see the error here http://www.alkemica.net/operatori-olistici/


Sergey
Total posts: 13,748
13 Mar 2014 10:54

I have not yet released version with fix.

Powered by Cobalt