Home >Backend Development >PHP Tutorial >Example of thinkphp paging class modified to imitate dedecms drop-down paging style, dedecmsthinkphp_PHP tutorial
The example in this article describes the thinkphp paging class modified to imitate the dede drop-down paging style. Share it with everyone for your reference. The specific implementation method is as follows:
Modify thinkphp paging class: such as drop-down list paging (similar to dedecms paging):
Pure html code:
Modify Page class operations:
Page.class.php page, relevant part of the original code:
After modification:
The page effect is as shown below:
I hope this article will be helpful to everyone’s ThinkPHP programming design.
Use the setConfig method in the paging class to customize the paging style:
I have a custom paging class that I used before. You can change it here.
/** * * Enter public paging class* @param array $map paging filtering conditions* @param class $Form data model* @param integer $limit number of items displayed in paging* @param string $order Sorting* @return array */ public function _list($map,$Form,$limit=9,$order='add_time'){ $res=array(); $p=empty($_GET['p']) ? 0 : (int)$_GET['p']; $res['list'] = $Form->field(true)->where($map)->order($order)-> page($p.','.$limit)->select();import('ORG.Util.Page'); // Import paging class $count = $Form->where($map)-> ;count();// Query the total number of records that meet the requirements $Page = new Page($count,$limit);// Instantiate the paging class and pass in the total number of records and the number of records displayed on each page $Page-> rollPage=3;$Page->setConfig('theme'," %upPage% %linkPage% %downPage%
You can use more data to divide into several pages, and then check the source code to see the css of the paging code. Add a style sheet and it will be ok
div.meneame{padding:3px;font-size:80%;margin :3px;color:#ff6500;text-align:center;}div.meneame a{border:#ff9600 1px solid;padding:5px 7px;background-position:50% bottom;background-image:url(../images /meneame.jpg);margin:0 3px 0 0;text-decoration:none;}div.meneame a:hover{border:#ff9600 1px solid;background-image:none;color:#ff6500;background-color:# ffc794;}div.meneame a:active{border:#ff9600 1px solid;background-image:none;color:#ff6500;background-color:#ffc794;}div.meneame span.current{border:#ff6500 1px solid; padding:5px 7px;font-weight:bold;color:#ff6500;margin:0 3px 0 0;background-color:#ffbe94;}div.meneame span.disabled{border:#ffe3c6 1px solid;padding:5px 7px; color:#ffe3c6;margin:0 3px 0 0;}