Thinkphp paging class instance that is similar to dedecms drop-down paging style modification, dedecmsthinkphp
This example describes the thinkphp paging class modified by the dede drop-down paging style. Share it with you for your reference. The specific implementation method is as follows:
Modify the thinkphp paging class: The following pull paging (similar to dedecms paging ):
Pure html code:
Copy codeThe Code is as follows: <select name = "sldd" style = "width: 36px" onchange = "location. href = this. options [this. selectedIndex]. value;">
<Option value = "http: // URL/1"> 1 </option>
<Option value = "http: // URL/2" selected = "selected"> 2 </option>
</Select>
Modify Page operations:
Page. class. php Page, the relevant original code:
Copy codeThe Code is as follows: $ linkPage = "";
For ($ I = 1; $ I <= $ this-> rollPage; $ I ++ ){
$ Page = ($ nowCoolPage-1) * $ this-> rollPage + $ I;
If ($ page! = $ This-> nowPage ){
If ($ page <= $ this-> totalPages ){
$ LinkPage. = "<a href = '". $ url. "&". $ p. "= $ page'>". $ page. "</a> ";
} Else {
Break;
}
} Else {
If ($ this-> totalPages! = 1 ){
$ LinkPage. = "<span class = 'current'>". $ page. "</span> ";
}
}
}
After modification:
Copy codeThe Code is as follows: $ linkPage = "<select name = 'sldd' style = 'width: 36px 'onchange = 'location. href = this. options [this. selectedIndex]. value; '> ";
For ($ I = 1; $ I <= $ this-> rollPage; $ I ++ ){
$ Page = ($ nowCoolPage-1) * $ this-> rollPage + $ I;
If ($ page! = $ This-> nowPage ){
If ($ page <= $ this-> totalPages ){
$ LinkPage. = "<option value = '". $ url. "&". $ p. "= $ page'>". $ page. "</option> ";
} Else {
Break;
}
} Else {
If ($ this-> totalPages! = 1 ){
$ LinkPage. = "<option value = '". $ url. "'selected = 'selected'>". $ page. "</option> ";
}
}
}
$ LinkPage. = "</select> ";
Shows the page effect:
I hope this article will help you with ThinkPHP programming.
How to change the page pages and THINKPHP kernel, for example, http: // wwwttplmgcom/special/8 html
Use the setConfig method in the paging class to customize the paging style:
I have a previously used custom paging class. Let's change it.
/***** Enter public paging class * @ param array $ map paging filter condition * @ param class $ Form data model * @ param integer $ number of lines displayed on the limit page * @ param string $ order sorting * @ return array */public function _ list ($ map, $ Form, $ limit = 9, $ order = 'add _ Time') {$ res = array (); $ p = empty ($ _ GET ['P'])? 0: (int) $ _ GET ['P']; $ res ['LIST'] = $ Form-> field (true)-> where ($ map) -> order ($ order)-> page ($ p. ','. $ limit)-> select (); import ('org. util. page '); // import the paging class $ count = $ Form-> where ($ map)-> count (); // query the total number of records meeting the requirements $ Page = new Page ($ count, $ limit ); // The total number of incoming records and the number of records displayed on each Page in the instantiated paging class $ Page-> rollPage = 3; $ Page-> setConfig ('Theme ', "% upPage % linkPage % downPage % <li style = 'width: 50px; '> <a href = 'javascript: void (0) '> % nowPage %/% totalPage % page </a> </li> "); $ res ['page'] = $ Page-> show (); // return $ res ;}
How does thinkphp paging style change? Answer
You can use a few more data pages and view the source code to view the css of the paging code and add a style sheet.
Div. meneame {padding: 3px; font-size: 80%; margin: 3px; color: # ff6500; text-align: center;} div. meneame a {border: # ff9600 1px solid; padding: 5px 7px; background-position: 50% bottom; background-image: url (.. /images/meneame.jpg); margin: 0 3px 0 0; text-decoration: none;} div. meneame a: hover {border: # ff9600 1px solid; background-image: none; color: # ff6500; background-color: # ffc794;} div. meneame a: active {border: # ff9600 1px solid; background-image: none; color: # ff6500; background-color: # ffc794;} div. meneame span. current {border: # ff6500 1px solid; padding: 5px 7px; font-weight: bold; color: # ff6500; margin: 0 3px 0 0; background-color: # ffbe94 ;} div. meneame span. disabled {border: # ffe3c6 1px solid; padding: 5px 7px; color: # ffe3c6; margin: 0 3px 0 0 ;}