Skip to content

Instantly share code, notes, and snippets.

@allyraza
Created October 17, 2012 06:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allyraza/eee790c9d06e0e9c6360 to your computer and use it in GitHub Desktop.
Save allyraza/eee790c9d06e0e9c6360 to your computer and use it in GitHub Desktop.
// 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