Yii Framework Forum: Star Rating - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Star Rating Rate Topic: -----

#1 User is offline   Deram 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 48
  • Joined: 07-June 12

Posted 25 February 2013 - 04:21 PM

Hi guys, i'm currently creating an application with the star rating widget.
What i'm looking to achieve is that a person should only be allowed to have one rate of a product, but he may update his rating if he chooses. Therefore the system should check if a rating of that user on that product already exist. If i does, the default value of the stars should be the rating he/she submitted last time, and if the user chooses to submit again, this row in the database table should be updated. If no rating on that product has been done by this user before, he/she should be see empty stars, and if any rating is submitted this would create a new row in the database table.

I have some ideas on how some of this would be made, but i can be wrong about the method. I'm particular unsure of how the application should check wether the user already have a rating on that product.

Can you guys please help me?
0

#2 User is offline   le_top 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 386
  • Joined: 08-June 10
  • Location:France (Ile-de-France/Val d'Oise)

Posted 25 February 2013 - 04:37 PM

I think there is a rating extension somewhere in the extension - have you checked that out?
0

#3 User is offline   samilo 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 231
  • Joined: 04-October 12

Posted 25 February 2013 - 04:58 PM

Dear Dream

To do that you need to follow those steps :

1- add table to save rating action
for example

id - user_id - post_id - date - rate
rate( rate value )

2- when user will rate some post for example data will save in above table .

3- if user will change him rate then you need to check your table :
a- if user had no raw in table insert new one if else go to (B)
b- call function to return user data where post = current post and user_id= $user_id
c- if old rate != new $rate then update record with new value

That is :)

rate action will be like that :

 public function actionRate(){
 	
 	/// note user id you can get it from session or any method u saved it befor 
 	
 	if(isset($_GET['post_id']))   {
    	
  	$post_id=intval($_POST['post_id']);
  	$new_rate=intval($_POST['new_rate']);
  	
 	$model=rate::model()->find("user_id=$user_id and post_id=$post_id"); 
 	
 	if($model===null){/// So no old recorde 
    	
    	//// insert new value in table 
 	}
 	else{
    	
  	$old_rate=$model->rate;
  	if($old_rate!== $new_rate)  {
   	$model->rate=$new_rate;
   	$model->save(false); 
    	
  	}
    	
 	}  
    	
    	
 	}
    	
    	
	}

0

#4 User is offline   C.S.Putera 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 92
  • Joined: 18-May 11

Posted 25 February 2013 - 10:30 PM

Hello, this extension perhaps ?
0

#5 User is offline   Deram 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 48
  • Joined: 07-June 12

Posted 26 February 2013 - 10:05 AM

Hey guys, thanks for answering.

Samilo's answer was the one i was looking for, and thank you very much for that.
I've already looked at the extension Putera is referring to, but it can't do some of what i want.

So again, thanks for helping me out on this :)
0

#6 User is offline   ketcz 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 11-November 13

Posted 26 March 2014 - 05:54 AM

plz any1 can place a complete demo of how to apply css on cstarrating??????
0

#7 User is offline   Neminath 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 30-March 14

Posted 30 March 2014 - 03:42 AM

Please can any one help me, i am new user to yii, i am doing star rating
ex:giving user to rate some product so please anyone provide detail steps.

Presently am using for my appliction yii farmework and yii booster

And i seached in google but all are using cstar rating so it will be conflict to yii booster..

So can anyone please guide me through this..
0

#8 User is offline   Rohit Suthar 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 218
  • Joined: 12-May 14
  • Location:Mumbai, India

Posted 04 July 2014 - 07:22 AM

for best help follow this wiki -

Managing a star rating with the StarRating widget in Yii 2

and use Star Rating Yii Widget..
Thanks & regards,

ROHIT SUTHAR
Mumbai(India)

Follow me - @rohisuthar

www.yiiframework.us
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users