We provide various official and user-released code examples and code reference. You are welcome to exchange and learn how to get stuck with me for a long time while configuring short routes during website creation, the Page cannot be modified by yourself. class. php class enable support for short paging Routing
First, I am a cainiao. If there is anything bad, don't be surprised. When I configured a short route for my website, I had to spend a long time, and finally I had no way to modify the Page myself. class. php class supports short routing. I added the following configuration items to the class:
// Enable short paging Routing
'Is _ SHORT '=> 0, // 1 IS enabled, 0 IS disabled, and default IS disabled
// Start with a short paging route '/^ c _ (\ d +) $/' starts with c and starts with 'C' by default
'Url _ ASGIN '=> 'C ',
// Brief paging route separator '/^ c _ (\ d +) $/' starts with _ and uses '_' as the default delimiter
'Url _ splits '=> '_',
Added
$ IsShort parameter to determine whether to enable short paging routing (disabled by default ).
The main usage is:
Class ArticleListAction extends CommonAction {
Public function index (){
$ Cid = I ('id', 0 );
If ($ cid ){
$ Blog = M ('blog ');
$ Where = array ('del _ id' => 0, 'cid' => $ cid );
Import ('class. page', APP_PATH); // import the paging Class
$ Count = $ blog-> where ($ where)-> count (); // query the total number of records meeting the requirements
$ Page = new Page ($ count,); // instantiate the total number of incoming records and the number of records displayed on each Page. The third parameter is to enable short paging routing.
$ Show = $ Page-> show (); // display the output by Page
// Perform paging data query. Note that the parameters of the limit Method must use the attributes of the Page class.
$ This-> blog = $ list = $ blog-> where ($ where)-> order ('datetime desc')-> limit ($ Page-> firstRow, $ Page-> listRows)-> select ();
$ This-> list = $ show;
$ This-> display ();
}
}
}
Online Demo: http://wei416978817.byethost33.com/
Page.class.rar (2.07 KB download: 185 times)
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB