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 = preg_match('/\?/', $link) ? '&' : '?'; $pages = array(); if ($page != 0) { $pages['First'] = $link."page=0"; $pages['Prev'] = $link."page=".($page - 1); } if (($page + 1) < $num_pages) { $pages['Next'] = $link."page=".($page + 1); $pages['Last'] = $link."page=".($num_pages - 1); } $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; } // $start = max($page - $before_after_display_pages, 0); // $end = min($page + $before_after_display_pages, $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."page={$i}"; } } $smarty->assign($name, $pages); } ?>