#1 tealin
一、控制器中的代码:
class donate extends spController
{
function index(){
$lib_donate = spClass("lib_donate");
$this->results = $lib_donate->spPager($this->spArgs("page",1),10)->findAll($conditions = null, $sort="id desc");
$pager=$lib_donate->spPager()->getPager();
//dump($pager);
$this->pager=$pager;
$this->c=$this->spArgs("c");
$this->a=$this->spArgs("a");
$this->display("donate/show.html");
}
?>
二、视图中的代码
{if $pager}
共有记录{$pager.total_count}条,共有{$pager.total_page}页(每页{$pager.page_size}条):
{$max_page=10}
{$start_page=floor($pager.current_page/$max_page)*$pager.page_size+1}
{if ($start_page+$max_page)<=$pager.total_page}
{$end_page=$start_page+$max_page-1}
{else}
{$end_page=$pager.total_page}
{/if}
{if $start_page <= 1 and $pager.current_page <= 1 }
首 |
« |
{elseif $pager.current_page > 1 and $pager.total_page <= $max_page}
首 |
« |
{else}
首 |
« |
-{$max_page} |
{/if}
{foreach from = $pager.all_pages item = thepage}
{if $thepage <= $end_page and $thepage >= $start_page}
{if $thepage == $pager.current_page}
{$thepage} |
{else}
{$thepage} |
{/if}
{/if}
{/foreach}
{if $end_page == $pager.total_page }
{if $pager.current_page == $pager.last_page}
» |
尾 |
{else}
» |
尾 |
{/if}
{else}
+{$max_page} |
» |
尾 |
{/if}
{/if}
2014-04-15 19:39:18