|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
doge Smarty n00b
Joined: 03 Dec 2019 Posts: 3
|
Posted: Thu Dec 12, 2019 5:10 am Post subject: Smarty Pagination Function |
|
|
Help me on error cause paginator function.
I made this function in smarty
Code: | <?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Smarty {paginator} function plugin
*
* Type: function<br>
* Name: paginator<br>
* Purpose: create pages links<br>
* @param array
* @param Smarty
*/
function smarty_function_paginator($params, &$smarty)
{
$col = $params['col'];
$cur = $params['cur'];
$url = $params['url'];
$delta = $params['delta'] ? $params['delta'] : 5;
echo '<div class="pages">';
if ($cur > 2)
echo '<a href="' . sprintf($url, 1) .'" class="first"><<<</a>';
if ($cur > 1)
echo '<a href="' . sprintf($url, $cur-1) .'" class="prev"><<</a>';
$start = $cur - $delta;
if ($start < 1) $start = 1;
$end = $cur + $delta;
if ($end > $col) $end = $col;
for ($i = $start; $i <= $end; $i++) {
if ($i == $cur) {
echo '<b>'.$i.'</b>';
} else {
echo '<a href="' . sprintf($url, $i) .'" class="page">'.$i.'</a>';
}
}
if ($cur < $col-1)
echo '<a href="' . sprintf($url, $cur+1) .'" class="prev">>></a>';
if ($cur < $col)
echo '<a href="' . sprintf($url, $col) .'" class="first">>>></a>';
echo '</div>';
return;
}
/* vim: set expandtab: */
?>
|
In index.php I set like this
Code: | $groupspages = array(
"cur" => $pages,
"onpage" => $pagination,
"col" => 3
);
$smarty->assign('pages', $groupspages); |
Then in my template I call it
Code: | {paginator col=$pages.col cur=$pages.cur} |
But seems nothing work here, can anybody help me? |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|