Home > Backend Development > PHP Tutorial > thinkphp5 paging style, tp5 paging style

thinkphp5 paging style, tp5 paging style

PHP中文网
Release: 2023-03-15 17:16:01
Original
5896 people have browsed it

tihinkphp's built-in paging style sometimes cannot meet the requirements of the project. Here we mainly introduce the customization and beautification of the paging style to make it more concise and beautiful thinkphp5 controller writing method

   function index($keyword='', $page = 1){
        $map = [];
        if ($keyword) {
            $map['code'] = ['like', "%{$keyword}%"];
        }
        $list=Db('package')->where($map)->paginate(10, false, ['page' => $page]);
        return $this->fetch('index',['list'=>$list,'keyword'=>$keyword]);
    }
Copy after login

Template writing method

/*循环输出数据*/ 
  {foreach $list as $vo}
      id {$vo.id}
   {/foreach}
/*分页写法*/ 
  {$list->render()}
Copy after login

Pagination style

<style>
/*分页*/
.pagination {}
.pagination li {display: inline-block;margin-right: -1px;padding: 5px;border: 1px solid #e2e2e2;min-width: 20px;text-align: center;}
.pagination li.active {background: #009688;color: #fff;border: 1px solid #009688;}
.pagination li a {display: block;text-align: center;}
</style>
Copy after login


The above is the detailed content of thinkphp5 paging style, tp5 paging style. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template