Zend Framework Implementation Message page function (with demo source download), zenddemo_php tutorial

Source: Internet
Author: User
Tags zend framework

Zend Framework Implementation Message Sub-page function (with demo source download), Zenddemo


The example of this paper describes the Zend Framework implementation of the Message page function method. Share to everyone for your reference, as follows:

The paging function here uses the. Zend_paginator This component to implement the message on this page ... Here I am also a reference phpchina in a phper wrote this tutorial

My implementation of the bad environment and the project directory is written on the basis of the third tutorial. If a friend does not understand the arrangement of what the catalogue is. Please use ZF1.6.0 above. Please find this tutorial in the previous article. I don't have much to say here. Thank you..

The first step: in our controller, that is indexcontroller.php found indexaction this action. We can see that. In this action, we only take the data for the relevant tutorials. We will now rewrite this action to the following form: The following code (with annotations):

function indexaction () {$message =new message ();//Instantiate database class//Take all messages getallmessage,getallremessage// Two methods defined in model (message.php)//Fetch all reply data $this->view->arrreviews= $message->getallremessage (); $page =1;// The default page $numperpage = 3;//The number of bars displayed per page if (isset ($_get[' page ')) && is_numeric ($_get[' page ')) {$page = $_get[' page '];// Fetch the URL to pass over the page digital} $array = $message->getallmessage ();//Take all message data $paginator = Zend_paginator::factory ($array); $ Paginator->setcurrentpagenumber ($page)->setitemcountperpage ($numPerPage); $this->view->paginator = $ Paginator;echo $this->view->render (' header.phtml ');//display modulo masthead file echo $this->view->render (' message/ Index.phtml ');//display template echo $this->view->render (' footer.phtml ');//Display template foot file} 

Step two: Fix the style that we want to page, here is the style of pagination with an HTML setting ... In the Zend Framework Manual. Provides three ways to display pagination ... You can take a look at their usage. In fact, it's very simple. I used the first of its kind. We will create a new template page in the views/scripts/directory pagestyle.phtml. This template page is the same level as the message book header.phtml and footer.phtml. Because we may use this paging method in the future. So I put it here.:p the agestyle.phtml code is as follows: (Note: Here please define your web_root as a global variable in your portal file index.php, it is your site root directory!):

if ($this->pagecount):? >class= "Paginationcontrol" > if (isset ($this->previous)):?> "index/index/? page=previous;?> ">< prev | else:?> class= "Disabled" >< Previous | endif;?> foreach ($this->pagesinrange as $page):?>  if ($page! = $this->current):?> "index/index/? Page= "> $page;?> |  else:?>   = $page;?> |  endif;?> Endforeach;?> if (Isset ($this->next)):?> "Index/index/?page=next;?>" > Next > Else:?> C lass= "Disabled" > Next > endif;?> endif;?>

The third step: Find the message this display page of the INDEX.PTHML template page, the original:

foreach ($this->messages as $message):?>

This change

if (count ($this->paginator)):?> $i = 1; foreach ($this->paginator as $message):?>

After that. We'll add a page to the last display:

= $this->paginationcontrol ($this->paginator, ' Elastic ', ' pagestyle.phtml ');?>

This way. We'll be able to see our message paged.

Full instance code click here to download this site.

More interested in Zend related content readers can view the topic: "Zend framework of the introductory tutorial", "PHP Excellent Development Framework Summary", "Yii framework Introduction and common skills Summary", "thinkphp Introductory Tutorial", "PHP object-oriented Programming introduction tutorial "," Introduction to Php+mysql Database Operation "and" PHP common database Operation Skills Summary "

It is hoped that this article will help you to design PHP based on the Zend Framework framework.

Articles you may be interested in:

    • Zend Framework Introduction Environment configuration and the first Hello World example (with demo source download)
    • Zend Framework Introductory Knowledge Point Summary
    • Zend Framework 2.0 Event Manager (the EventManager) Getting Started tutorial
    • Zend Framework Smarty Extension Implementation method
    • Code analysis of routing mechanism of Zend framework framework
    • Zend Framework implementation of basic functions of the message book (with demo source download)
    • The Zend framework implements the method of storing the session in Memcache
    • Zend Framework implements multi-file upload function instances
    • Zend Framework Cache Usage Simple instance
    • Zend Framework basic Page Layout analysis
    • Zend Framework+smarty Usage Example detailed
    • Zend Framework Custom Helper Class Considerations Summary
    • Introduction to Zend Framework Development Classic Tutorial

http://www.bkjia.com/PHPjc/1113721.html www.bkjia.com true http://www.bkjia.com/PHPjc/1113721.html techarticle Zend Framework Implementation message This page features (with demo source download), Zenddemo This article describes the Zend framework implementation of the message page function of the method. Share to everyone for reference, with ...

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