Pagination - the Awkward Way!

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

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: [Jason] Pagination - the Awkward Way!

Hi, Jason -

Thanks for your tips but I think there's a bit more to it than that...

The problem is how to generate/assign the correct page number to the link.

Part of the pagination code block looks like this...
<?php foreach (range(1,$itemRecordMetaData['totalRecords']) as $page): ?>
<?php if ($page == $current_page): ?>
<strong><?php echo $page; ?></strong>
<?php else: ?>
<a href="./index.php?category=<?php echo $selectedCategory['num'] ?>&page=<?php echo $WHAT['num'] ?>">Link</a>
<?php endif ?>
<?php endforeach; ?>

The foreach loop does not pass down any record information - so there is no way to pull the record 'num' into the link.

If I were to use $page it would just be an arbitrary number which wouldn't match the actual record number as required by whereRecordNumberInUrl(1).

:0S

Perch

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