-
-
Save allyraza/eee790c9d06e0e9c6360 to your computer and use it in GitHub Desktop.
This file contains 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
// your controller code | |
<?php | |
public function actionIndex() | |
{ | |
$path = dirname(__FILE__); | |
$data = file($path."/../data/data.txt"); // you can move all this stuff into a model or use a method | |
$dataProvider=new CArrayDataProvider($data, array( | |
'pagination'=>array( | |
'pageSize'=>10, | |
), | |
)); | |
// print_r($dataProvider->getData()); // will return a list of arrays. | |
$this->render('index', array( | |
'dataProvider' => $dataProvider, | |
)); | |
} | |
?> | |
// your view with CListView | |
<?php | |
$this->widget('zii.widgets.CListView', array( | |
'dataProvider'=>$dataProvider, | |
'itemView'=>'_view', // refers to the partial view named '_post' | |
)); | |
?> | |
// here is your _view partial | |
<div id="view"> | |
<?php echo $data;?> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment