Enable Page. class. php of ThinkPHP to support short paging Routing

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.