Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Zend Framework Blog:
Paginating data collections with zend-paginator
Feb 02, 2017 @ 16:26:13

The Zend Framework blog has continued with its series of posts highlighting a component of the framework and some of the benefits and functionality it brings to the table. In their latest post they focus on zend-paginator for easy and automatic pagination of results.

zend-paginator is a flexible component for paginating collections of data and presenting that data to users. Pagination is a standard UI solution to manage the visualization of lists of items, like a list of posts in a blog or a list of products in an online store.

zend-paginator is very popular among Zend Framework developers, and it's often used with zend-view, thanks to the pagination control view helper zend-view provides. It can be used also with other template engines. In this article, I will demonstrate how to use it with Plates.

The tutorial starts with the Composer command to get the component pulled into your project and details what all comes with it. It then shows the creation of a custom adapter type (for "Posts"") and how to use the package to paginate through the results with an example of the output here. Then comes the example using the Plates templating framework via a "PaginatorMiddleware" middleware, a simple template using the pagination object directly and inserting the page navigation via a partial (again making use of the object but getting the values needed to build out the links).

tagged: zendframework pagination zendpaginator plates templating tutorial

Link: https://framework.zend.com/blog/2017-01-31-zend-paginator.html

Lee Davis' Blog:
Zend Paginator Example
Apr 19, 2012 @ 15:31:29

In a recent post to his blog Lee Davis gives an example of using the Zend Framework's pagination functionality, complete with some CSS to style it a bit better than the defaults.

One of the reasons why zend framework has been so popular is due to all the hard work put in to make sure components are extremely configurable. Sure there are default behaviours, but nothing is assumed and anything that needs to be overwritten or reconfigured can be. A strong emphasis on configuration over convention means you’ll never be lumbered with code that just can’t be changed. Zend Paginator is one of the smaller components of Zend Framework that allows you to get a simple paginator up and running on your listings or search pages in a matter of minutes.

Included in the post is a cut-and-pasteable view that creates the Previous/Next links as well as including the first/last page numbers and a few around the current page.

tagged: zendframework zendpaginator tutorial view css

Link:

Till Klampaeckel's Blog:
Iterating over a table (with Zend_Db_Table and Zend_Paginator)
Oct 12, 2011 @ 16:01:44

Till Klampaeckel has a new post today looking at a solution for a common need - paginating through results as pulled from a database. With the help of the Zend_Db_Table and Zend_Paginator components of the Zend Framework it's a simple matter of passing the results into the Paginator and asking for a certain page.

So frequently, I need to run small data migrations or transformations. Especially on the way to Doctrine, there's a lot to clean-up in a database which has been used and evolved over five years or so.

Code snippets are included to define a class for the table, extending Zend_Db_Table_Abstract, and a new Zend_Paginator_Adapter_DbTableSelect object to create the paginated results. After that, it's as simple as setting the number of items per page and asking for a certain page. There's even a quick bit about being able to edit the rows inside the paginator directly (they're just Zend_Db_Table_Row records).

tagged: tutorial iterate table zendframework zenddbtable zendpaginator

Link:

Rob Allen's Blog:
Exploring Zend_Paginator
May 04, 2011 @ 16:26:57

Rob Allen has a new post today exploring Zend_Paginator and some of the features it has to offer.

One area of displaying lists on web pages that I've generally disliked doing is pagination as it's a bit of a faff. Recently, I needed to do just this though as I couldn't delegate it as my colleague was too busy on other work. As a result, I thought that I should look into Zend_Paginator this time. Turns out that it's really easy to use and the documentation is great too.

He includes some sample code to set up the paginator (for his example it uses a data mapper) and push the results from the database into the Zend_Paginator object. He shows how to use the paginator to work through the results, pulling a page number from the URL. Finally, he shows the HTML to include the pagination links into your page.

tagged: zendframework zendpaginator tutorial example

Link:

Joey Rivera's Blog:
Using Zend_Paginator with Twitter API and Zend_Cache
Jan 29, 2010 @ 16:54:44

In a recent post to his blog Joey Rivera looks at using the Zend_paginator component with Twitter and APC to create a cachable, paged view of a set of Twitter API results.

I'm going to focus more on Zend_Paginator and Zend_Rest_Client to access Twitters API since I've already created a post on Zend_Cache. Normally, I would use Zend_Service_Twitter to access the twitter service but it still seems to require authentication to retrieve a users timeline where only protected users should require authentication.

He includes all of the needed code including the bootstrap.ini file and his own custom Twitter service class that grabs the timeline of the given user and calls the REST interface to grab the latest posts and caches them to a file.

tagged: zendpaginator zendcache tutorial twitter api

Link:

Ibuildings Blog:
Zend_Paginator: First Impressions
Dec 02, 2008 @ 13:53:52

Lorna Mitchell has posted an article to the Ibuildings blog looking at the Zend_Paginator component of the Zend Frameworks, some of her first impressions.

The idea of this module is to allow collections of data to be paginated. It takes the set, restricts the results, and can also generate the page numbers you need to move around between the resulting paginated data. Basically it saves me writing the same pagination code multiple times and then having to fix the bug where the last result on the previous page appears on the next ... all this has been thought of already.

She shows how it works with a simple example - paginating results from a database table, setting the count per page and the current page number. This object is pushed out to the view and rendered (in her case) via a Smarty template.

tagged: zendpaginator component zendframework impression example

Link:

Anis Ahmad's Blog:
Join Problems with Zend_Paginator and Zend_Db_Select objects
Aug 28, 2008 @ 16:18:55

Anis Ahmad had a problem. The Zend_Paginator component of the Zend Framework, while powerful, wasn't quite working right. Bugs popped up when he used a join along with a Zend_Db_Select.

One of the 4 Adapters for Zend_Paginator is DbSelect which uses a Zend_Db_Select instance. Now, the problem occurred if I need to have some calculative data from other tables and use join with the Zend_Db_Select object for them.

He gives an example of a join that he performed with the component, the details of the "behind the scenes" code and why it happened that way. He also offers a solution (before the Zend_Pagination component was patched for it, of course) of changing the count() method it uses slightly to remove an unneeded part of the query.

tagged: zendpaginator zenddbselect component zendframework

Link:


Trending Topics: