Thinkphp3.2.2 customizing paging links and improving Paging

Source: Internet
Author: User
Provides various official and user-released code examples. For code reference, you are welcome to learn thinkphp 3.2.2 custom paging links and paging improvements.
When using THINKPHP for a project, I am used to writing pseudo-static link addresses. Recently, I upgraded THINKPHP to THINKPHP 3.2.2. The paging of the article is always the link generated by the U method. I used to use the pseudo-static link address, but I was confused. I seldom go to the THINKPHP manual, and I am not very familiar with THINKPHP route rewriting. It took a lot of time to find information, but it was not appropriate. In the end, it is not necessary to return to the page. class. php class that comes with THINKPHP. Open it and check that there is no custom page Link Configuration.

Modified page. class. php: http://www.jb100.net/html/content-28-303-1.html

The script 100 below will share with you how THINKPHP 3.2.2 custom paging links. Please forgive me for any errors.
.
1. Add 'link' => ''to the $ config array '',
Private $ config = array (
'Header' => '% TOTAL_ROW % records in total ',
'Prev' => 'previous page ',
'Next' => 'Next page ',
'First' => '1 ...',
'Last' => '... % TOTAL_PAGE % ',
'Theme '=>' % HEADER % FIRST % UP_PAGE % LINK_PAGE % DOWN_PAGE % END % ',
'Link' => '',
);
2. Modify the private function url function to the following private function url($page){
if($this->config['link']){
return str_replace('[PAGE]', $page, $this->url);
}else{
return str_replace(urlencode('[PAGE]'), $page, $this->url);
}

}
3. Change $ this-> url = U (ACTION_NAME, $ this-> parameter) in the public function show function to the following if($this->config['link']){
$this->url = str_replace('zz', $this->parameter['p'], $this->config['link']);
}else{
$this->url = U(ACTION_NAME, $this->parameter);
}
After completing the preceding steps, THINKPHP 3.2.2 can implement the custom paging link function.

Paging links are customized, but how can we use them? The following is an example. $ Com = M ('Article as ');
$ Count = $ com-> where ($ where)-> count ();
$ Page = new \ Think \ Page ($ count, 2 );
$ List = $ com-> fiel ('A. title, a. article_id, a. picurl, a. content, a. author, a. add_time, c. cat_name ')
-> Where ($ where)-> join ('ja _ article_cat as c on c. cat_id = a. cat_id ')
-> Order ('a. add_time desc ')-> limit ($ Page-> firstRow.', '. $ Page-> listRows)-> select ();
// Echo $ com-> getLastSql ();


$ Page-> setConfig ('header ',"");
$ Page-> setConfig ('prev', "Previous Page ");
$ Page-> setConfig ('Next', 'Next ');
If ($ keyword ){
$ Page-> setConfig ('link', 'circle-'. $ id. "-". $ keyword. "-p-zz.html ");
} Else {
$ Page-> setConfig ('link', 'cycle-'. $ id. "-p-zz.html ");
}

$ PageLink = $ Page-> show ();
In addition to custom page links, but also the page. class. php optimization, friends can download the need, the modified page. class. php: http://www.jb100.net/html/content-28-303-1.html

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.