Phpcms custom tab pagination in custom modules, phpcms pagination _php Tutorial

Source: Internet
Author: User

Phpcms custom tab pagination in custom modules, Phpcms page


If you are an experienced phpcms two times developers, this article can be ignored, because the wording of this is very disgusting
Today in the development of a website self-built a module called Forum module, directory name: Luntan
In the Forum list page, you need to display all the posts and need pagination to display, according to the PHPCMS default template label definition way
{Pc:luntan action= "get_send" num= "2" page= "$_get[page]"} Follow this notation in the program data[' limit ' = ' 0,2 ' but data[page] = NULL
This can not receive the page number, but because of personal level research does not understand here should be how to put the paging method in the system to load and make it easy to use, tangled up a long time to come up with a faint recruit, I hope you correct, and if there are good suggestions I hope you can at any time, teach me a bit
To get a list of forum posts, you need a way to get it, as follows

 Public functionGet_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; }

Notice the Echo $pages _send on the line above the return; In fact, it is borrowed from the background using pagination method so that the page can be normal display of page numbers, and can do jump
But if you unlock the echo $pages _send, then there's no way to control where it's displayed in the page, so that he can show it my way, and add a method underneath it.

  public   function  get_send_page ( $data  ) { 
  
    $page  = 
    empty  (
    $_get  [' page '])?            1: 
    intval  (
    $_get  [' page ' 
   ]);  
    $send _info  = 
    $this ->luntan_send->listinfo (
    $where  = ", 
    $            Order  = ', 
    $page , 
    $pagesize  = 
   );             
    $pages _send  = 
    $this ->luntan_send-> 
    pages;             
    echo  
    $pages _send  
   ;         
    return  
    $send _info  
   ; }
  

See the name of the two methods different, get_send and get_send_page a page, so that in the function code inside the latter because only need to display the page number, and the former only need to display the data, you can get_ The call and output mask used in the Send method to get page numbers, i.e.
$pages _send = $this->luntan_send->pages;
......
echo $pages _send;
In the latter Get_send_page method, there is no need for the next for loop to process the data as to what data is returned is not important, the main thing is to use the echo out of the page, so the two functions the same part of the
$page = Empty ($_get[' page ')? 1:intval ($_get[' page ');
$send _info = $this->luntan_send->listinfo ($where = ", $order =", $page, $pagesize = 20);
If you want to change the number of pages displayed in the default page, you need a colleague to modify two methods
$send _info = $this->luntan_send->listinfo ($where = ", $order =", $page, $pagesize = 20); $pagesize variable of a sentence

http://www.bkjia.com/PHPjc/976451.html www.bkjia.com true http://www.bkjia.com/PHPjc/976451.html techarticle phpcms custom tab pagination in custom modules, phpcms pagination If you are an experienced phpcms two times developer, this article can be ignored because the writing here is from ...

  • 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.