I have the following method that creates and returns a markup for the pagination link in PHP.
public function getPaginationLinks ($ option) {if ($ option ['total_pages']> 1) {$ markup =' & lt; Div class = "pagination" & gt; '; If ($ option ['page']> 1) {$ markup. = '& Lt; A href = '? Page = '. ($ Option ['page'] - 1). ((Isset ($ options [Order_by ']))? "& Sort =". $ Options [' order_by ']: "").' '& Gt; & Lt; Previous & lt; / A & gt; '; } ($ I = 1; $ i & lt; = $ options ['total_pages']; $ i ++) {if ($ option ['page'] = $ i) {$ markup = '& Lt; A href = "? Page = '. $ I. ((Isset ($ options [' order_by '])? & Amp; sort =". $ Options [' order_by ']: "").' '& Gt;' . $ I. '& Lt; / A & gt; '; } And {$ markup. = '& Lt; Span class = "current" & gt; . $ I. '& Lt; / Span & gt; '; }} If ($ option ['Page'] & lt; $ option ['total_pages']) {$ markup. = '& Lt; A href = "? Page = '. ($ Option [' page '] + 1). ([Order- $' ['order_by']))"? & Amp; Sort = ". $ Options ['order_by']:" "). ' '& Gt; Next & gt; & lt; / a & gt;'} $ markup. '' & Lt; / div & gt; Return $ markup;} Other {return false;}}
I recently discovered (to surprise me) that I had reached 70 + pages which means 70+ links are now shown below.
< P> I'm thinking that someone can help me break it ... I'm not sure that the number of works that is being shown to show the numbers works as much .. Pages 30, thoughts?
You can see the current page in the previous and previous and lower x
(Say 4) pages.
If you are on Page 1:
, then 1 2 3 4 5
andStrong> Page 70:
« »
Code> For example.
Example:
$ x = 4; ($ I = $ currentPage - $ x; $ i & lt; $ currentPage; $ i ++) {if ($ i> = 1) {/ * Show link * /} Other {/ * Show Eelpices and Fixes Counter * / $ I = 1; }} / * Show current page number without link / ($ i = $ current page + 1; $ i
You can also apply, which is Uber Cool. =)
Update: One more.
Comments
Post a Comment