Hello there. After using Yii for new projects for a while now I am wanting to use Yii code in a 3rd party app. I am currently trying to use CGridView like so:
However I keep getting CSort and CPagination errors because both classes try to call createUrl() using the controller object and there is no controller object. My question is how do I create a controller object for an app that only calls Yii::createWebApplication('../includes/yii_config.php'); Is this even possible? If I remove pagination and sorting then it works but I know I am missing some fundamental knowledge about how to generate a dummy controller. I.E a controller that is only instantiated so CSort and CPagination can call the necessary controller methods.
//CGridView Widget $model = new SaveExport; Yii::import('zii.widgets.grid.*'); $grid = new CGridView; $grid->dataProvider = $model->search(); $grid->filter = $model; $grid->columns = array( array( 'name'=>'name', 'sortable'=>false, ), array( 'name'=>'tag', 'sortable'=>true, ), array( 'header'=>'Date', 'name'=>'date_time', 'sortable'=>false, ), ); $grid->init(); $grid->run(); //The model->search(); public function search() { $criteria=new CDbCriteria; $criteria->compare('id',$this->id); $criteria->compare('name',$this->name,true); $criteria->compare('tag',$this->tag,true); $criteria->compare('date_time',$this->date_time,true); return new CActiveDataProvider($this, array( 'criteria'=>$criteria, 'pagination'=>array( 'pageSize'=>10, ), )); }
However I keep getting CSort and CPagination errors because both classes try to call createUrl() using the controller object and there is no controller object. My question is how do I create a controller object for an app that only calls Yii::createWebApplication('../includes/yii_config.php'); Is this even possible? If I remove pagination and sorting then it works but I know I am missing some fundamental knowledge about how to generate a dummy controller. I.E a controller that is only instantiated so CSort and CPagination can call the necessary controller methods.