Yii Framework Forum: How can I do a pagination without a table? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How can I do a pagination without a table? Rate Topic: -----

#1 User is offline   GodFather 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 91
  • Joined: 19-July 09

Posted 24 February 2010 - 02:38 PM

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;
    $pages->applyLimit($criteria);

    $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>
  <ul>
    <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>
  </ul>
</div>
<? } ?>


where am I wrong?

Thanks.
0

#2 User is offline   bettor 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 744
  • Joined: 02-February 09

Posted 25 February 2010 - 04:50 AM

View PostGodFather, on 24 February 2010 - 02:38 PM, said:

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>
  <ul>
    <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>
  </ul>
</div>
<? } ?>


where am I wrong?

Thanks.



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

#3 User is offline   GodFather 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 91
  • Joined: 19-July 09

Posted 25 February 2010 - 06:50 AM

bettor,

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?

thanks,
0

#4 User is offline   bettor 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 744
  • Joined: 02-February 09

Posted 25 February 2010 - 07:03 AM

View PostGodFather, on 25 February 2010 - 06:50 AM, said:

bettor,

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?

thanks,



Try
<?php $this->widget('CLinkPager',array('pages'=>$pages)); ?>
after foreach function.

[not tested]
0

#5 User is offline   GodFather 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 91
  • Joined: 19-July 09

Posted 25 February 2010 - 08:26 AM

Is working now, thanks.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users