Home  >  Article  >  PHP Framework  >  ThinkPHP5 custom paging URL

ThinkPHP5 custom paging URL

angryTom
angryTomforward
2020-03-21 09:50:253467browse

This article introduces the method of implementing custom paging URL in ThinkPHP5. Most of the time, the paging that comes with TP5 cannot meet the development needs. At this time, we need to customize the paging URL.

ThinkPHP5 custom paging URL

ThinkPHP5 custom paging URL

When doing news or products, the URL often jumps with parameters, for example: www.xxx.com/redcm/news/newslist.html?classid=13

TP5’s own paging function, the default URL is like this: www.xxx.com/redcm/news/newslist.html? page=1

(Recommended tutorial: thinkphp tutorial)

So the paging that comes with TP5 cannot meet people’s normal use in most cases. We need to customize the paging url. The code is as follows:

ThinkPHP5 custom paging URL

The above is for viewing only, and the one here is for everyone to copy and paste~ ~

$where['query']['classid'] = $classid;
$newsList = Db::name('infolist')->where(['status' => 1,'classid' => $classid])->paginate(1,'',$where);

After adding this line of code, the paging url becomes: www.xxx.com/redcm/news/newslist.html?classid=13&page=2

So understand that the classid after query is What's up~ ~

PHP Chinese website, a large number of free high-definition website construction tutorials, welcome to learn online!

The above is the detailed content of ThinkPHP5 custom paging URL. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete