How can I do a pagination without a table?

Hi guys,

I’m try to create a pagination on my front end view, the pageSize works fine, but the pagination don’t show up on the page footer.

my action is so:

  public function actionIndex()


    $this->action  = 'index';

    $criteria = new CDbCriteria;

    $pages    = new CPagination(Answer::model()->recent()->count($criteria));

    $pages->pageSize = 5;


    $answers = Answer::model()->recent()->findAll($criteria);

    $this->render('index', array('answers' => $answers, 'pages' => $pages));


and the view:

<? if(Yii::app()->user->hasFlash('voted')){ ?>

<p class="txt_yellow_duplicated_vote"><?php echo Yii::app()->user->getFlash('voted'); ?></p>

<? } ?>

<? foreach($answers as $k => $v) { ?>

<div class="post clearfix">

  <span class="date_time"><?= date("M d, Y,  g:i a", strtotime($v->created_at));?></span>

  <p><?= $v->text; ?></p>


    <li><a href="/reply/<?= $v->id; ?>" title="Repiles">Repiles (<?= count($v->comments) ?>)</a></li>

    <li><a href="/thumbs/up/<?= $v->id; ?>" title="Thumbs up" class="ico_up">Thumbs up (<?= $v->thumbs_up ? $v->thumbs_up : 0; ?>)</a></li>

    <li><a href="/thumbs/down/<?= $v->id; ?>" title="Thumbs down" class="ico_down">Thumbs down (<?= $v->thumbs_down ? $v->thumbs_down : 0; ?>)</a></li>



<? } ?>

where am I wrong?


It could be just me…but where exactly do you render the $pages in your veiw file?


it’s the problem, normally when I use the yii default template the pagination is automatic, a do this and the pagination show up automatic when the pageSize is exceeded, but in this case I need to use a very customized template and I don’t now what is missing.

How do you normally do this?



<?php $this->widget('CLinkPager',array('pages'=>$pages)); ?>

after foreach function.

[not tested]

Is working now, thanks.