Custom tag paging in the Custom module of phpcms, and phpcms Paging

Source: Internet
Author: User

Custom tag paging in the Custom module of phpcms, and phpcms Paging

If you are an experienced secondary developer of phpcms, this article is negligible, because the writing here is quite disgusting.
Today, I developed a self-built Forum module for a website named luntan.
All posts must be displayed on the Forum list page and displayed by page. The default phpcms template defines the tag.
{Pc: luntan action = "get_send" num = "2" page = "$ _ GET [page]"} in the program, data ['limit'] = '0, 2' but data [page] = NULL
In this way, the page number is not received, but the individual level research does not understand how to load the paging method in the system and make it easy to use. After a long time, I have come up with a bad trick. I hope you can correct me, if you have any good suggestions, I hope you can give me some advice at any time.
To obtain the list of Forum posts, You need to obtain the following method:

public function get_send($data){            $page = empty($_GET['page']) ? 1 : intval($_GET['page']);            $send_info = $this->luntan_send->listinfo($where = '', $order = '', $page, $pagesize = 20);            //$pages_send = $this->luntan_send->pages;            for($i = 0; $i < count($send_info); $i++){                $type_info = $this->luntan_type->get_one(array('type_id'=>$send_info[$i]['send_type_id']));                $send_info[$i]['send_type_name'] = $type_info['type_name'];                $reply_info = $this->luntan_reply->get_one(array('reply_send_id'=>$send_info[$i]['send_id']),'count(*) as reply_send_num');                $send_info[$i]['send_reply_num'] = $reply_info['reply_send_num'];            }            //echo $pages_send;            return $send_info;        }

Note the echo $ pages_send in the line above the return; here, we actually use the paging method in the background to make the page display normal page numbers, and we can do the jump
However, if you unlock the echo $ pages_send;, you cannot control the display position on the page, so that he can display it as needed, another method is added below this method,

public function get_send_page($data){            $page = empty($_GET['page']) ? 1 : intval($_GET['page']);            $send_info = $this->luntan_send->listinfo($where = '', $order = '', $page, $pagesize = 20);            $pages_send = $this->luntan_send->pages;            echo $pages_send;            return $send_info;        }

The names of the two methods are different. get_send and get_send_page have a different page. In this way, the latter only needs to display the page number, while the former only needs to display the data, you can call the get_send method to obtain the page number and shield the output, that is
// $ Pages_send = $ this-> luntan_send-> pages;
......
// Echo $ pages_send;
In the get_send_page method, the next for loop is not required to process the data. It does not matter what data is returned. The main difference is to use the echo page, so the same part of the two functions is
$ Page = empty ($ _ GET ['page'])? 1: intval ($ _ GET ['page']);
$ Send_info = $ this-> luntan_send-> listinfo ($ where = '', $ order ='', $ page, $ pagesize = 20 );
If you want to modify the number displayed on the default page, you need to modify
$ Send_info = $ this-> luntan_send-> listinfo ($ where = '', $ order ='', $ page, $ pagesize = 20); $ pagesize variable in a sentence

 

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.