discuz 自定义分页函数
- function get_page($num,$perpage=12,$page,$url,$maxnum){ if(!$num)return ; $perpage=max(1,$perpage); $upage=max(1,$page-1); $tpage=$num%$perpage?intval($num/$perpage)+1:intval($num/$perpage); if($tpage==1)return; $page=min($page,$tpage); $nextpage=min(($page+1),$tpage); $html='<div class="pagination">'; $html.='<div class="page-item"><a href="'.$url."&page=$upage".'" class="page-link"><</a></div>'; for($i=0;$i<=2*$maxnum;$i++){ $thispage=$page-$maxnum+$i; if(($thispage>=1)&&($thispage<=$tpage)){ if($thispage==$page){ $html.='<div class="page-item active"><a class="page-link">'.$thispage.'</a></div>'; }else{ $html.='<div class="page-item"><a href="'.$url."&page=$thispage".'" class="page-link">'.$thispage.'</a></div>'; } } } $html.='<div class="page-item"><a href="'.$url."&page=$nextpage".'" class="page-link">></a></div></div>'; return $html; }