Javascript automatically converts ThinkPHP pagination to bootstrap pagination and thinkphpbootstrap

Source: Internet
Author: User

Javascript automatically converts ThinkPHP pagination to bootstrap pagination and thinkphpbootstrap

# Write a common paging HTML generated by thinkphp, which is automatically converted to bootstrap pagination:

/*** @ Author default7 # zbphp.com * @ description converts ThinkPHP pages to bootstrap pages * @ param selector */function initPagination (selector) {selector = selector | '. page '; $ (selector ). each (function (I, o) {var html = '<ul class = "pagination">'; $ (o ). find ('a, span '). each (function (i2, o2) {var linkHtml = ''; if ($ (o2 ). is ('A') {linkHtml = '<a href = "' + ($ (o2 ). attr ('href ') |' # ') +' "> '+ $(o2 ). text () + '</a>';} else if ($ (o2 ). is ('span ') {linkHtml =' <a> '+ $(o2 ). text () + '</a>';} var css = ''; if ($ (o2 ). hasClass ('current') {css = 'class = "active "';} html + = '<li' + css + '>' + linkHtml + '</li>';}); html + = '</ul> '; authorization (o).html (html ). fadeIn ();});}



How to change the page pages and THINKPHP kernel, for example, http: // wwwttplmgcom/special/8 html

Use the setConfig method in the paging class to customize the paging style:
I have a previously used custom paging class. Let's change it.

/***** Enter public paging class * @ param array $ map paging filter condition * @ param class $ Form data model * @ param integer $ number of lines displayed on the limit page * @ 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 the paging class $ count = $ Form-> where ($ map)-> count (); // query the total number of records meeting the requirements $ Page = new Page ($ count, $ limit ); // The total number of incoming records and the number of records displayed on each Page in the instantiated paging class $ Page-> rollPage = 3; $ Page-> setConfig ('Theme ', "% upPage % linkPage % downPage % <li style = 'width: 50px; '> <a href = 'javascript: void (0) '> % nowPage %/% totalPage % page </a> </li> "); $ res ['page'] = $ Page-> show (); // return $ res ;}

The bootstrap effect cannot be displayed after the display template in thinkphp

Brother, is your path correct? Create a Publuc folder under the project folder and change it to the absolute path. Replace the path with the ThinkPHP template constant _ PUBLIC _.

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.