Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function getPagination($current = 1, $totalPages, $start = 1)
- {
- global $config;
- $smarty = new Smarty();
- $smarty->template_dir = $config['path']['root'].'templates/newdesign/';
- $smarty->compile_dir = $config['path']['root'].'tmp/';
- // логика пагинации
- $pagination = '<a href="#">«</a>';
- for($i = 1; $i <= $totalPages; $i++)
- {
- $activeClass = $i <= $current ? "active" : "";
- $page = str_replace("&ajax=".$current,"&page=".$i, $_SERVER['REQUEST_URI']); //текущая страница и заменяем слово ajax на page
- if($i <= $current+3)
- {
- $pagination .= '<a class="'. $activeClass .'" href="' . $page . '">' . $i . '</a>';
- } elseif ($i > $totalPages-3) {
- if($i == $totalPages-2)
- $pagination .= "<a href='#'>....</a>";
- $pagination .= '<a href="' . $page . '">' . $i . '</a>';
- }
- }
- $pagination .= '<a href="#">»</a>';
- // передача данных в шаблон
- $smarty->assign('pagination', $pagination);
- // вывод шаблона пагинации
- return $smarty->fetch('include/common/pagination.tmpl');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement