klox7 VIP
Total posts: 914
10 Jan 2014 07:40

I just noticed something when using different strings for total rating. I have now 2 reviews, one with result 9 and one with 5.3 (I devided results by 10).

If I echo

<?php echo ($item->votes_result)/10;?>

it gives 7,1 as a result. If I echo

<?php echo $rating['total']/10 ?>

it gives 7,2 a result. Actual result is 7,15.

I would just like to know which way is more proper to use? Thanks.

Last Modified: 02 Oct 2014

Comments have been disabled for this article and works only in read only mode.

Sergey
Total posts: 13,748
13 Jan 2014 02:04

both ways a proper.

But first way does not make additional query. It means that I would use that method in the article list if possible.

Second method add one new query with is ok if we are in full article view.

Also you can use round($int, $decimal)


klox7 VIP
Total posts: 914
11 Feb 2014 02:52

Ok, I'm back on this now... Please check

Hidden text

I have 3x code for rating (just for testing), one at the top and 2 at the bottom. I have bolded how it is coded. I'm asking why every rating has different value?

Another thing is this. I'm using custom template for comments in record (same link as before). But if I use same template as my review list (as separate section) then I get errors for using $item->votes_result.

Hidden text


Sergey
Total posts: 13,748
11 Feb 2014 07:18

Second link no permisions to access.

The difference may exists in case you have approve system for reviews. $rating['total'] contain total of all published articles. $item->votes_result contain all articles including unpublished.


klox7 VIP
Total posts: 914
11 Feb 2014 08:01

So $item->votes_result will calculate new rating only when edit of review is approved, otherwise it will show old rating?

Sorry, I'm trying to set second link to public but no luck. Here is the notice which prevents rating being calcuated:

Notice: Undefined variable: item in components/com_cobalt/views/records/tmpl/default_list_termespa_resort_reviews.php on line 49

where template is a list template and the code for rating is $item->votes_result/10.

I had 3 comments and now I deleted one. I still don't get it why for the same code ($item->votes_result/10) displays 2 different results (one 5,2 which is ok, and one 9).


Sergey
Total posts: 13,748
11 Feb 2014 23:57

Notice: Undefined variable: item in components/com_cobalt/views/records/tmpl/default_list_termespa_resort_reviews.php on line 49

where template is a list template and the code for rating is $item->votes_result/10.

May be you enter this code outside of foreach?

Notice: Undefined variable: item in components/com_cobalt/views/records/tmpl/default_list_termespa_resort_reviews.php on line 49

where template is a list template and the code for rating is $item->votes_result/10.

I had 3 comments and now I deleted one. I still don't get it why for the same code ($item->votes_result/10) displays 2 different results (one 5,2 which is ok, and one 9).

This is also problem. ON delere rating is not recalculated.

In other words you ought to use $rating['total'] everywhere.


klox7 VIP
Total posts: 914
01 Oct 2014 15:46

klox7 I had 3 comments and now I deleted one. I still don't get it why for the same code ($item->votes_result/10) displays 2 different results (one 5,2 which is ok, and one 9). Sergey This is also problem. ON delere rating is not recalculated.

Did you maybe change this or is rating still not recalculated?


Sergey
Total posts: 13,748
02 Oct 2014 01:43

I cannot change it. THat is why API was created to solve this problem.

Powered by Cobalt