Created
June 22, 2013 14:07
-
-
Save ertankayalar/5840995 to your computer and use it in GitHub Desktop.
yii active data provider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $dataProvider=new CActiveDataProvider('Post', array( | |
| 'criteria'=>array( | |
| 'condition'=>'status=1', | |
| 'order'=>'create_time DESC', | |
| 'with'=>array('author'), | |
| ), | |
| 'pagination'=>array( | |
| 'pageSize'=>20, | |
| ), | |
| )); | |
| $this->render('index', array('dataProvider' => $dataProvider)); | |
| // $dataProvider->getData() will return a list of Post objects | |
| // view/index.php | |
| ?> | |
| <?php $this->widget('zii.widgets.CListView', array( | |
| 'dataProvider'=>$dataProvider, | |
| 'itemView'=>'_view', | |
| )); ?> | |
| <?php | |
| // _view.php | |
| ?> | |
| <div class="view"> | |
| <?php echo CHtml::image($data->getCoverImage()); ?> | |
| <?php echo CHtml::encode($data->publishedtext); ?> | |
| <br /> | |
| <?php echo CHtml::link(CHtml::encode($data->property_name), array('update', 'id'=>$data->id)); ?> | |
| <br /> | |
| <b><?php echo CHtml::encode($data->getAttributeLabel('user_id')); ?>:</b> | |
| <?php echo CHtml::encode($data->username); ?> | |
| <br /> | |
| </div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment