Osclass Support Forums
Osclass plugin support => User Rating Plugin => Topic started by: SpekeMedia on September 08, 2018, 03:29:08 PM
-
how can i show the number of reviews next to the users star rating
how it is now:
*****
how i would like it:
***** (23 reviews)
-
@SpekeMedia
Currently after stars is shown average rating.
In functions.php of plugin, you may find:
getRatingAverageByUserId
and replace with:
countRatingsByUserIdAll
And in ModelUR.php add function:
// COUNT RATINGS ON USER
public function countRatingsByUserIdAll( $user_id, $user_email) {
$this->dao->select('count(*) as i_count');
$this->dao->from( $this->getTable_Rating() );
if($user_id == 0 || $user_id == '') {
$this->dao->where('s_user_email', $user_email);
} else {
$this->dao->where('fk_i_user_id', $user_id);
}
$result = $this->dao->get();
if( !$result ) { return array(); }
return $result->row();
}
-
Hi thanks so much! sorry i'm a little bit slow i think i done it wrong
I replaced
$global_rating = ModelUR::newInstance()->getRatingAverageByUserId($user_id, $user_email, 9, $validate);
with
$global_rating = ModelUR::newInstance()->countRatingsByUserIdAll($user_id, $user_email, 9, $validate);
and added the function to the bottom of ModelUR.php but it breaks the site, bringing up white screen.
regards.
-
@SpekeMedia
At end of model is one extra } that close model.
-
i think maybe a issue with my theme, had another weird issue before with my current theme. i added the function and the closing } now the site is back but now nothing is displayed where i've put the shortcode, example:
https://www.gwolla.co.uk/food-drinks/nescafe-3in1-original-strong-brown-sugar-eu-made_174
i understand you can't provide support on my theme but thanks for the code above.
-
@SpekeMedia
Revert changes and add code into middle of file after some function.
-
<b>Fatal error</b>: Uncaught Error: Unsupported operand types in ....plugins\user_rating\functions.php:128
125. function ur_get_stars($rating) {
126. $html = '';
127. $color = ur_user_color($rating);
128. $help_rating = $rating * 2;
Keep getting the error above after implementing the changes
-
@luke
I do not see any unsupported operands there.
-
@SpekeMedia
Currently after stars is shown average rating.
In functions.php of plugin, you may find:
getRatingAverageByUserId
and replace with:
countRatingsByUserIdAll
And in ModelUR.php add function:
// COUNT RATINGS ON USER
public function countRatingsByUserIdAll( $user_id, $user_email) {
$this->dao->select('count(*) as i_count');
$this->dao->from( $this->getTable_Rating() );
if($user_id == 0 || $user_id == '') {
$this->dao->where('s_user_email', $user_email);
} else {
$this->dao->where('fk_i_user_id', $user_id);
}
$result = $this->dao->get();
if( !$result ) { return array(); }
return $result->row();
}
What diffrent is:
getRatingAverageByUserId and countRatingsByUserIdAll
in my mind when get rating are that the user can input the rating.
-
@omadmin
Functions are not same, difference must be checked in model. Both returns data in different format.