Thinkphp and bootstrap combine to create a personalized pagination style

Source: Internet
Author: User
This article mainly introduces the thinkphp and bootstrap to create a personalized page style (recommended) related information, very good, with reference value, the need for friends can refer to the next

First Spit Groove ThinkPHP3.1 version of the page style, although it seems very simple and generous, but all the page numbers are all using simple numbers, the gap between the smaller, not easy point, and the "first 5 pages" and "5 pages" seems a bit redundant, because click on the current display of the first page of "previous" The button will naturally come out on the top 5 pages.

3.1 of the paging effect is like this:

In view of the above all the less ideal situation, coupled with the recent study of ThinkPHP5, in the THINKPHP5 provides the bootstrap page style perfect support, As long as the Bootstrap.css file is introduced in THINKPHP5, the foreground will naturally be displayed in the bootstrap style after using the paging function in the controller, and the effect is like this:

While I developed the top for the network when THINKPHP5 has not come out, using the 3.1 version, then in the 3.1 version of how to use the bootstrap paging component? The following are the workarounds:

1. Native page.class.php classes derived from thinkphp

In order not to affect the core file (violating the design pattern of the change closure principle), I derived a subclass Listpage, the subclass code is as follows:

Import (' ORG. Util.page ');//Import Page class Listpage extends page {//For the system user controller features override the related function in the page class/**   * pagination Display output   * @access public   *  /protected $config = Array (' header ' = ' record ', ' prev ' = ' < ', ' next ' = ' > ',  ' first ' = ') ' << ', ' last ' = ' >> ',  ' theme ' = '%first%%uppage%%linkpage%%downpage% ');  ......

As you can see, the files that are in the core class are imported first, and then they can be boldly derived, and only the core code is listed here. We just need to modify the config variable in the page class, override the variable in the subclass as above, and then use that subclass in all the action (Controller) to create the paging object:

$Page =new listpage ($count, 5);

This will allow us to use the above settings, OK, done, the new pagination display results are as follows:

The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.