Thinkphp of the page class is very commonly used a class, so particularly detailed look at the source record down to facilitate their own review, here thinkphp is 3.23 version, but no matter which version same, as long as you understand the source code, changed the version will not change the nature.
First of all, the interpretation of the source code, but due to the ability to express the problem may not be so clear.
<?php//+----------------------------------------------------------------------//| thinkphp [WE CAN do it JUST it]//+----------------------------------------------------------------------//|
Copyright (c) 2006-2014 http://thinkphp.cn All rights reserved. // +----------------------------------------------------------------------
// | Licensed (http://www.apache.org/licenses/LICENSE-2.0)//+------------------------------------------------------- ---------------
// | Author: Mai Miao Le <zuojiazi@vip.qq.com>
The following is an example of the use of interpretation, in fact, I think the example is not so important, it is important to understand the source code, even if there is no instance can be very clear how to use, but in order to more clearly, or here in detail put a few examples.
The following is the pagination page style for the instance:
PHP Code:
<?php
namespace Home\controller;
Use Think\controller;
Class Indexcontroller extends Controller {public
function index () {
$page =new \think\page (200,10);
$page->setconfig (' first ', ' home ');
$page->setconfig (' prev ', ' prev ');
$page->setconfig (' Next ', ' next page ');
$page->lastsuffix=false;//To change the style of the last page, is to set to false, otherwise it will not succeed, the above source has read why this
$page->setconfig (' Last ', ' End ') );
$show = $page->show ();
$this->assign ("page", $show);
$this->display (' page ');
}
HTML code:
<! DOCTYPE html>
If you want to change the display format of the page number, here are two examples, one is to remove the end of the display, one is to add total pages of the display:
First of all, to remove the end of the display only need to add this article in the above code:
$page->setconfig (' theme ', '%first%%up_page%%link_page%%down_page% ');
Display as shown in figure:
Here's how to add the total number of pages shown, in fact, only need to $config[' theme '] in the change.
$page->setconfig (' header ', ' <span class= ' rows ' >%now_page%/%total_row% strips </span> ');
$page->setconfig (' theme ', '%first%%up_page%%link_page%%down_page%%end% ');
Above I have made some changes to the display of the total number of pages, showing the following: