简体   繁体   中英

How can I show stars in yii cstarrating extension?

Hey I am working on cstarraing extension of yii. I am using the following code to show the stars from database :

   $criteria = new CDbCriteria();
        $count=Reviews::model()->count($criteria);
        $pages=new CPagination($count);
        $criteria->order="time DESC";
        $criteria->condition="user_id=".$_GET['user_id']." AND status='approve'";
        // results per page
        $pages->pageSize=3;
        $pages->applyLimit($criteria);

        $review = Reviews::model()->findAll($criteria);
        $i=1;
        foreach($review as $review)
        {
           $rate=$review['rating'];
           $this->widget('CStarRating',array(
                'name'=>'rating'.$i,
                'minRating'=>1,
                'maxRating'=>5,
                'starCount'=>5,
                'value'=>$rate,
                'readOnly'=>true,
            ));
            echo "<br/>";
            echo $review['title'];
            echo "<br/>";
            echo "<font color='brown'>".ucfirst($review['name'])."</font><br/>";
            echo $review['body'];
            echo "<br/>";
            echo "Posted on : ".$review['time'];
            echo "<hr/><br/>";
            $i++;
        }
$this->widget('CLinkPager', array(
    'pages' => $pages,
)) ?>

I am getting evering thing ok but I am not getting Stars (*) in my review form, instead I am getting radio buttons ? how can i get them back , thanks

I had the same problem while developing an application with Yii. The radio buttons change to stars if appropriate CSS file is loaded. So check html ids, spans and see if you have corresponding field in your CSS files. You also need to have images of stars(background,foreground) on your server. I solved it by manually download the original jquery patch, and used it's included CSS file and images.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM