I'm twiting

访问统计

free counters

cakephp分页功能(paginator)

在controller里定义属性:

var $paginate = array(
‘Group’ => array(
‘limit’ => 10
));

在action抓数据的时候用:

$groups = $this->paginate( ‘Group’, $conditions );
$this->set( ‘groups’, $groups );

在需要用到分页的地方加上:

<?php echo $this->renderElement(’pagination’); ?>

然后cake会去找pagination.ctp这个element的。贴一下我的分页:

<form action=”<?php echo preg_replace(’/page:(\d+)/’, ”, $paginator->url()); ?>”>
<table width=”95%” border=”0″ align=”center” cellpadding=”8″ cellspacing=”0″>
<tr>
<td width=”65%” colspan=”7″ align=”center” bgcolor=”#FFFFFF” style=”font-size:14px;”>
当前页<span class=”font_orange”><?php echo  $paginator->current(); ?></span>
总页数<span class=”font_blue”><?php echo $paginator->counter(array( ‘format’ => ‘%pages%’ )); ?></span>
<?php echo $paginator->first(’首页’); ?>
<?php echo $paginator->prev( ‘上一页’ ); ?>
<?php echo $paginator->numbers( array( ’separator’ => ‘&nbsp;&nbsp;&nbsp;’, ‘modulus’ => 5 ) ); ?>
<?php echo $paginator->next(’下一页’); ?>
<?php echo $paginator->last(’末页’); ?>
跳转<input type=”text” name=”page” id=”page” class=”input_sr” style=”width:20px;”/>页
<input type=”submit” value=”提交” />
</td>
</tr>
</table>
</form>

Share on Facebook

1 comment to cakephp分页功能(paginator)

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>