list items per page and pagination

4 posts by 2 authors in: Forums > CMS Builder
Last Post: June 15, 2011   (RSS)

By ikanizaj - June 14, 2011

Is it possible to create 20 items per page, but that pagination goes ten records at the time.

What I would like is to create first ten items displaying title, images, summary, etc. and next ten items only title.

Then I would like, when I click on next page, to display ten items (from the first page that had only titles) with title, images, summary, and next ten items with only titles? Is that possible?
--
Igor Kani¾aj

Re: [Jason] list items per page and pagination

By ikanizaj - June 14, 2011

no no, 20 items on every page. First ten with more detail, and other ten with just title. But on second page, first ten with more detail should be the one that were just title on previous page.
--
Igor Kani¾aj

Re: [ikanizaj] list items per page and pagination

By Jason - June 15, 2011

Hi Igor,

Sure, you will have to use the offset & limit method. You can set your offset variable like this:

$page = intval(@$_REQUEST['page']);
$offset = (($page - 1) * 10) - 1;
if ($offset < 0) { $offset = 0;}

list ($articleRecords, $articleMetaData) = getRecords(array(
'tableName' => 'articles',
'allowSearch' => false,
'offset' => $offset,
'limit' => 20,
));


The one issue here is that if you look at the metaData variable, you won't have the page numbers and prevPageLink/nextPageLink automatically generated for you. You will have access to totalRecords, pageResultsStart, and pageResultsEnd. You'll have to manually create your links that include the page numbers.

Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/