Pagination - the Awkward Way!

5 posts by 2 authors in: Forums > CMS Builder
Last Post: August 19, 2010   (RSS)

I want to set-up a form of pagination between (detail) pages assigned to the current $selectedCategory. I appreciate there is already a method of doing this, along the lines of...

.....

<a href="<?php echo $itemRecordMetaData['prevPageLink'] ?>">&lt;&lt; prev</a>

.....

<?php foreach (range(1,$RecordMetaData['totalPages']) as $page): ?>

.....

<a href="<?php echo $RecordMetaData['nextPageLink'] ?>">next &gt;&gt;</a>

.....


Although this structure is fine, it's intended for use on list pages so requires certain modifications to the list() code to make it work.

Also, the way in which the next/prev links function is different to the normal approach and can cause problems. (i.e. such pages do not use/require 'where' => whereRecordNumberInUrl(1) ).

My question is; can the pagination structure outlined above be configured in such a way as to generate normal links which do use whereRecordNumberInUrl(1)?

:oS

Perchpole

Re: [Perchpole] Pagination - the Awkward Way!

By Jason - August 18, 2010

Hi Perchpole,

Yes, you can create custom links for use in the pagination for pages that do use whereRecordNumberInUrl().

The best way to format your link would be like this:
myPage.php?num=RECORDNUMBER&page=PAGENUMBER

If you're using a format that doesn't use the num variable in the URL string (such as myPage.php?my-title-NUMBER), you can still do this by making sure the record number is the last number in the string (ie. myPage.php?page=PAGENUMBER&my-title-NUMBER)

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [Perchpole] Pagination - the Awkward Way!

By Jason - August 19, 2010

Hi,

I'm not sure if I completely understand what you're trying to do. The pagination is used when you are returning multiple records from the database but only want to display a certain number of them at a time. When you're using "whereRecordNumberInUrl()", you're trying to retrieve only 1 specific record. There would be no other pages.

Is the problem you're encountering that you're retrieve information from multiple tables at the page number in the url is interfering with other getRecords functions?

Let me know and I'll take a closer look into this.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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

Re: [Jason] Pagination - the Awkward Way!

Hi, Jason -

No worries. I spent much of last night and almost all of today pulling the structure apart and rebuilding it again how I want it. The result works quite well and I've learned a lot along the way into the bargain.

Essentially, it's a pagination system for detail pages. It looks identical to the method raised by Damon, here...

page count at bottom with prev next links

...but uses different data to set-up the page numbers and generate the links.

Once I've tidied things up I'll give the code a proper run out in the forum...

:0)

Perch