thinkphp Sub-page

Source: Internet
Author: User

One: Pagination method

/** * TODO basic pagination in the same code package, make foreground code less * @param $m model, reference Pass * @param $where query criteria * @param int $pagesize Query number per page * @return \think\ Page*/function GetPage (& $m, $where, $pagesize =Ten) {$m 1=clone $m;//Shallow copy a model$count = $mwhere($where)->count ();//operations such as join are reset after a habitual operation$m = $m 1;//to maintain a constant, shallow copy of a model$p =Newthink\page ($count, $pagesize); $p->lastsuffix=false; $p->setconfig ('Header','<li class= "Rows" > Total <b>%TOTAL_ROW%</b> Records &nbsp;&nbsp; <b>%list_row%</b per page > &nbsp;&nbsp; Section <b>%NOW_PAGE%</b> page/Total <b>%TOTAL_PAGE%</b> page </li>'); $p->setconfig ('prev','Previous Page'); $p->setconfig ('Next','Next Page'); $p->setconfig (' Last','last page'); $p->setconfig (' First','Home Page'); $p->setconfig ('Theme','%first%%up_page%%link_page%%down_page%%end%%header%'); $p->parameter=i ('get.'); $m->limit ($p->firstrow, $plistRows); return$p;}

The GetPage method can be placed in the TP framework of the application/common/common/function.php, this document can be specifically placed in a number of common methods, where can be called (such as: Controller files, view files, etc.).

Two: Calling paging method

  

$m =m ('products'); $p=getpage ($m, $where,ten); $list = $m->field (true),where($where)->order ('ID desc' ),select() $this->list=$list; page= $p->show ();

Then the view Code.

 

class="pagination"> {$page}</div>

Three: The last is the style of pagination, this style can also be implemented by themselves, simple.

  

. Pagination ul {Display:inline-Block; Margin-bottom:0; Margin-left:0; -webkit-border-radius:3px; -moz-border-radius:3px; Border-radius:3px; -webkit-box-shadow:01px 2px Rgba (0,0,0,0.05); -moz-box-shadow:01px 2px Rgba (0,0,0,0.05); Box-shadow:01px 2px Rgba (0,0,0,0.05);}. Pagination ul li {display:inline;}. Pagination ul li.rows { line-height:30px; Padding-left:5px;}. Pagination ul li.rows B{color: #f00}.pagination ul Li A,. Pagination ul Li span {float: Left;    PADDING:4PX 12px; Line-height:20px; Text-Decoration:none; Background-color: #fff; Background:url ('.. /images/bottom_bg.png') 0px 0px;    border:1px solid #d3dbde; /*border-left-width:0;*/margin-left:2px; Color: #08c;}.    Pagination ul Li a:hover{color:red; Background: #0088cc;}. Pagination ul Li.first-child a,. Pagination ul li.first-Child span {border-left-width:1px; -webkit-border-bottom-left-radius:3px; Border-bottom-left-radius:3px; -webkit-border-top-left-radius:3px; Border-top-left-radius:3px; -moz-border-radius-bottomleft:3px; -moz-border-radius-topleft:3px;}. Pagination ul. Disabled span,. Pagination ul. Disabled a,. pagination ul. Disabled a:hover {color: #999; cursor:default; background-color:transparent;}. Pagination ul. Active a,. Pagination ul. Active span {color: #999; cursor:default;}. Pagination ul Li A:hover,. Pagination ul. Active a,. Pagination ul. Active span {background-color: #f0c040;}. Pagination ul Li.last-child a,. Pagination ul li.last-Child span {-webkit-border-top-right-radius:3px; Border-top-right-radius:3px; -webkit-border-bottom-right-radius:3px; Border-bottom-right-radius:3px; -moz-border-radius-topright:3px; -moz-border-radius-bottomright:3px;}. Pagination ul li.current a{color: #f00; font-weight:bold; Background: #ddd}

thinkphp Sub-page

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.