clear_assign($name); return $content; } if ($num_pages < 2 ){ return false; } $max_display_pages = (floor($max_display_pages / 2) * 2)+ 1; // max_display_pages validation $delim = (substr($link, -1) == '/') ? '' : '/'; $pages = array(); if ($page != 0) { $pages['First'] = $link . $delim . "page/0" . $query_string; $pages['Prev'] = $link . $delim . "page/" . ($page - 1) . $query_string; } if (($page + 1) < $num_pages) { $pages['Next'] = $link . $delim . "page/" . ($page + 1) . $query_string; $pages['Last'] = $link . $delim . "page/" . ($num_pages - 1) . $query_string; } $pages['pages'] = array(); if ($num_pages > $max_display_pages) { $page_first = $page - floor($max_display_pages / 2); $page_last = $page + floor($max_display_pages / 2); if ($page_first < 0) { $page_last = $page_last - $page_first; $page_first = 0; } if ($page_last >= $num_pages) { $page_first = $page_first - ($page_last - $num_pages + 1); $page_last = $num_pages - 1; } } else { $page_first = 0; $page_last = $num_pages - 1; } for ($i = $page_first; $i <= $page_last; $i++ ){ if ($i == $page){ $pages['pages'][$i + 1] = false; }else { $pages['pages'][$i + 1] = $link . $delim . "page/{$i}" . $query_string; } } $smarty->assign($name, $pages); }