Controller Code:
public function actionIndex() {
$newsDataProvider = new CActiveDataProvider('News', array(
'criteria' => array(
'order' => 'news_date DESC',
),
'pagination' => array(
'pageSize' => 3,
),
));
$this->render('home', array(
'newsDataProvider' => $newsDataProvider,
));
}
Code in view:
echo CHtml::openTag('div', array(
'class' => 'span-14',
));
$this->widget('zii.widgets.CListView', array(
'dataProvider' => $newsDataProvider,
'itemView' => '_news',
'template' => '{items}\n{pager}',
));
echo CHtml::closeTag('div');
Code in partial view:
echo CHtml::openTag('div', array('class' => 'view'));
echo CHtml::openTag('strong') . CHtml::link($data->title, '/site/news/view?id=' . $data->id, array(
)) . CHtml::closeTag('strong');
echo CHtml::openTag('p', array()) . CHtml::closeTag('p');
echo CHtml::image($data->picture, '', array('width' => '300px', 'style' => 'float:right; padding-left: 10px;'));
echo CHtml::encode($data->summary);
echo CHtml::openTag('div', array('class' => 'clear')) . CHtml::closeTag('div');
echo CHtml::tag('br');
$news_date = new DateTime($data->news_date);
echo CHtml::openTag('em', array('style' => 'font-size: smaller; float: right;')) . 'Date created: ' . $news_date->format('d - m - Y') . CHtml::closeTag('em');
echo CHtml::openTag('div', array('class' => 'clear')) . CHtml::closeTag('div');
echo CHtml::closeTag('div');

Help











