Added the new pagination method.
git-svn-id: http://svn.cleancode.org/svn/pickles@19 4d10bc64-7434-11dc-a737-d2d0f8310089
This commit is contained in:
parent
6871bb0f57
commit
8ccfdc2d1a
2 changed files with 53 additions and 0 deletions
0
smarty/function.draw_pagination.php
Executable file
0
smarty/function.draw_pagination.php
Executable file
53
smarty/function.pagination.php
Executable file
53
smarty/function.pagination.php
Executable file
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
function smarty_function_pagination($params, &$smarty) {
|
||||||
|
if (empty($params['current'])) {
|
||||||
|
$smarty->trigger_error('assign: missing \'current\' parameter');
|
||||||
|
}
|
||||||
|
else if (empty($params['total'])) {
|
||||||
|
$smarty->trigger_error('assign: missing \'total\' parameter');
|
||||||
|
}
|
||||||
|
else if (empty($params['section'])) {
|
||||||
|
$smarty->trigger_error('assign: missing \'section\' parameter');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$current =& $params['current'];
|
||||||
|
$total =& $params['total'];
|
||||||
|
$section =& $params['section'];
|
||||||
|
|
||||||
|
$pagination = null;
|
||||||
|
|
||||||
|
// « = double
|
||||||
|
// &lsaquo = single
|
||||||
|
|
||||||
|
$first = '« First';
|
||||||
|
$last = 'Last »';
|
||||||
|
|
||||||
|
$prev = '« Previous';
|
||||||
|
$next = 'Next »';
|
||||||
|
|
||||||
|
/*
|
||||||
|
$pagination .= ' <span class="pagination">';
|
||||||
|
$pagination .= $current != $total ? '<a href="/blog/first">' . $first . '</a>' : $first;
|
||||||
|
$pagination .= '</span>';
|
||||||
|
*/
|
||||||
|
|
||||||
|
$pagination .= $current != 1 ? '<a href="/' . $section . '/' . ($current - 1) . '">' . $prev . '</a>' : '<span class="prev">' . $prev . '</span>';
|
||||||
|
|
||||||
|
for ($i = 1; $i <= $total; $i++) {
|
||||||
|
$pagination .= $i != $current ? '<a href="/' . $section . '/' . $i . '">' . $i . '</a>' : '<span class="current">' . $i . '</span>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$pagination .= $current != $total ? '<a href="/' . $section . '/' . ($current + 1) . '">' . $next . '</a>' : '<span class="next">' . $next . '</span>';
|
||||||
|
|
||||||
|
/*
|
||||||
|
$pagination .= ' <span class="pagination">';
|
||||||
|
$pagination .= $current != 1 ? '<a href="/blog/last">' . $last . '</a>' : $last;
|
||||||
|
$pagination .= '</span> ';
|
||||||
|
*/
|
||||||
|
|
||||||
|
return '<div id="pagination">' . $pagination . '</pagination>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
Loading…
Add table
Add a link
Reference in a new issue