secret
Created

  • Download Gist
gistfile1.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
// 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>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.