List page - page links/navigation

8 posts by 4 authors in: Forums > CMS Builder
Last Post: July 6, 2009   (RSS)

Re: [rjbathgate] List page - page links/navigation

By Dave - January 26, 2009

Hi Rob,

Try something like this:

<?php foreach (range(1,$productsMetaData['totalPages']) as $page): ?>
<?php $maxPageRange = 5; ?>
<?php if ($page > ($productsMetaData['totalPages'] + $maxPageRange)) { continue; } ?>
<?php if ($page < ($productsMetaData['totalPages'] - $maxPageRange)) { continue; } ?>

<?php echo $page; ?>
<?php endforeach; ?>


Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] List page - page links/navigation

Hi,

Thanks Dave, seems like it's almost there, but it's just showing the last 6 page numbers, rather than either side of what page you're on.

So when on page 3, it's showing the last 6 pages (say 40,41,42,43,44,45,46), instead of 1,2,3,4,5,6.

I will email you the URL for a demo.

Thanks
Rob

Re: [rjbathgate] List page - page links/navigation

By Dave - January 27, 2009

Rob,

Ahh, ok. We need the current page number. Display the variables in $productsMetaData like this:

<xmp><?php print_r($productsMetaData); ?></xmp>

Then find the one that has the current page number and replace $productsMetaData['totalPages'] with it in this code:

<?php if ($page > ($productsMetaData['totalPages'] + $maxPageRange)) { continue; } ?>
<?php if ($page < ($productsMetaData['totalPages'] - $maxPageRange)) { continue; } ?>

I think it's called $productsMetaData['page']

Let me know if that works for you.
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] List page - page links/navigation

Hi Dave,

Yes, it is 'page'

This code works a treat:

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

<?php $maxPageRange = 4; ?>
<?php if ($page > ($productsMetaData['page'] + $maxPageRange)) { continue; } ?>
<?php if ($page < ($productsMetaData['page'] - $maxPageRange)) { continue; } ?>

<?php echo $page; ?>

<?php endforeach; ?>


This gives you 4 pages either side of what page you are on.

Thanks Dave!
Rob

Re: [rjbathgate] List page - page links/navigation

By Dave - January 29, 2009

Great, glad to hear it's working! :)
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] List page - page links/navigation

By HDLLC - July 4, 2009

Thanks for the code example!

One question though... I tried that exact snippet, of course changing the variable name to my own. I get the numbers to display, but no links. And, as I progress to page 3, 4, and then five - using the already available next/previous - the number of pages at the bottom simply increases by one, or decreases by one.
So, if I start with page 1, I have 1-5 at the bottom (but no links).
If I go to page 2 - I get 1-6, and page three give me 1-7.

How can I limit this to just a page range of say 5 or so pages, and have each page link so that someone can jump to page 5, or a few pages ahead instead of just crawling through next/previous?

Thanks in advance!

--Jeff

Re: [HDLLC] List page - page links/navigation

By ross - July 6, 2009

Hi Jeff

Thanks for the update!

I think we might be getting a bit more advanced than we can handle in support. Would you mind sending me an email through consulting@interactivetools.com? We'll go over the options from there.

Thanks!
-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/