In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to use Thinkphp and Bootstrap to achieve paging, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.
First complain about the ThinkPHP3.1 version of the paging style, although it looks very simple and generous, but all the page numbers are using simple numbers, the gap between them is relatively small, not easy, and the "first 5 pages" and "back 5 pages" seem a bit superfluous, because clicking the "previous page" button on the first page currently displays the first five pages naturally.
The paging effect of 3.1 looks like this:
In view of the above unsatisfactory situations, coupled with the recent study of ThinkPHP5, perfect support for BootStrap paging style is provided in ThinkPHP5. As long as the BootStrap.css file is introduced in thinkphp5, after using the paging function in Controller, the foreground will naturally be displayed according to the BootStrap style, and the effect is as follows:
When I developed the top search network, ThinkPHP5 had not yet come out and used version 3.1, so how can I use the paging component of BootStrap in version 3.1? Here is the solution:
1. Native page.class.php classes derived from thinkphp
In order not to affect the core file (in violation of the closed-to-modify principle of the design pattern), I have derived a subclass ListPage with the following code:
Import ('ORG.Util.Page'); / import paging class class ListPage extends Page {/ / rewrite related functions in Page class / * paging display output * @ access public * / protected $config = array (' header'= > 'record', 'prev'= >', 'first'= >', 'theme'= >'% first%% upPage%% linkPage%% downPage%% end%') ……
As you can see, first import the file where the core class is located, and then you can boldly derive it, and only the core code is listed here. We just need to modify the Config variable in the page class, rewrite the variable to the above form in the subclass, and then use the subclass in all Action (Controller) to create a paging object, namely:
$Page=new ListPage ($count,5)
In this way, we can use the settings above. All right, done, the new paging display is as follows:
Thank you for reading this article carefully. I hope the article "how to use Thinkphp and Bootstrap to achieve pagination" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.