Called in the Portal file
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 = "";
if ($params [' Pager '] [' current_page ']! = $params [' Pager '] [' first_page ']) {
$url = Spurl ($params [' C '], $params [' a '], $args + Array ($pagerhandle + = $params [' Pager '] [' prev_page ']));
$html. = "< Prev";
} else {
$html. = "< Prev";
}
$offset = $params [' offset ']? $params [' offset ']: 200; Can be adjusted with offset=x in <{pager}>
foreach ($params [' Pager '] [' all_pages '] as $page) {
if ($page = = $params [' Pager '] [' current_page ']) {
$html. = "{$page}";
} else {
if ($params [' Pager '] [' current_page '] < $offset && $page < $offset) | |
($params [' Pager '] [' current_page '] > $params [' Pager '] [' last_page ']-$offset && $page > $params [' Pager '] [ ' Last_page ']-$offset) | |
($page < $params [' pager '] [' current_page '] + $offset && $page > $params [' Pager '] [' current_page ']-$offset)
) {
$url = Spurl ($params [' C '], $params [' a '], $args + Array ($pagerhandle + = $page));
$html. = "{$page}";
}
}
}
if ($params [' Pager '] [' current_page ']! = $params [' Pager '] [' last_page ']) {
$url = Spurl ($params [' C '], $params [' a '], $args + Array ($pagerhandle + = $params [' Pager '] [' next_page ']));
$html. = "Next >";
} else {
$html. = "Next >";
}
$html. = ';
return $html;
}
Template Invocation Method
<{pager pager= $pager myclass= "num" c= "News" a= "Newslist" offset=5}>
Used in the controller:
[PHP]
Information List
function Newslist () {
$newsobj = Spclass ("Lib_news");
The Sppager is used here, and the incoming page parameter is accepted with Spargs
$this->results = $newsobj->sppager ($this->spargs (' page ', 1), ()->findall (null, ' ID DESC ');
Here to get the paging data and send it to the Smarty template
$this->pager = $newsobj->sppager ()->getpager ();
$this->display ("admin/news_list.html");
}
CSS Styles
[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; Border-left: #ccc 1px solid; COLOR: #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; margin:2px; Border-left: #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; Border-left: #eee 1px solid; COLOR: #ddd; padding-top:2px; Border-bottom: #eee 1px solid
}
http://www.bkjia.com/PHPjc/477876.html www.bkjia.com true http://www.bkjia.com/PHPjc/477876.html techarticle call require (Sp_path./speedphp.php) on the portal file; require (App_path./include/functions.php); Sprun (); functions.php [PHP] Spaddviewfunction (Pager, __template_pager); Functio ...