在入口文件调用
require(SP_PATH . "/SpeedPHP.php");
require(APP_PATH . '/include/functions.php');
spRun();
functions.php
[php]
spAddViewFunction('pager', '__template_pager');
function __template_pager($params) {
if (!isset($params['pager']) || emptyempty($params['pager']))
return '';
$args = array();
foreach ($params as $k => $v)
if (!in_array($k, array('c', 'a', 'pager', 'myclass', 'mypage', 'offset')))
$args[$k] = $v;
$pagerhandle = isset($params['pager']['mypage']) ? $params['pager']['mypage'] : 'page';
$html = "
Template calling method
<{pager pager=$pager myclass="num" c="news" a="newslist" offset=5}>
For use within the controller:
[php]
//Information list
Function newslist() {
$newsobj = spClass("lib_news");
// spPager is used here, and spArgs is used to receive the incoming page parameters
$this->results = $newsobj->spPager($this->spArgs('page', 1), 12)->findAll(null, 'id DESC');
// Get the paging data here and send it to the smarty template
$this->pager = $newsobj->spPager()->getPager();
$this->display("admin/news_list.html");
}
CSS style
[css]
.num {
Clear:both; margin:0 auto; width:500px; padding:15px 0 0 0;
}
.num A {
BORDER-RIGHT: #ccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #ccc 1px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 2px; MARGIN: 2px; : #000; PADDING-TOP: 2px; BORDER-BOTTOM: #ccc 1px solid; TEXT-DECORATION: none
}
.num A:hover {
BORDER: #0080C0 1px solid; COLOR: #000;
}
.num A:active {
BORDER: #0080C0 1px solid; COLOR: #000;
}
.num SPAN.current {
BORDER-RIGHT: #0080C0 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #0080C0 1px solid; PADDING-LEFT: 5px; FONT-WEIGHT: bold; PADDING-BOTTOM: 2px; #0080C0 1px solid; COLOR: #fff; PADDING-TOP: 2px; BORDER-BOTTOM: #0080C0 1px solid; BACKGROUND-COLOR: #0080C0
}
.num SPAN.disabled {
BORDER-RIGHT: #eee 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #eee 1px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 2px; MARGIN: 2px; : #ddd; PADDING-TOP: 2px; BORDER-BOTTOM: #eee 1px solid
}