page count at bottom with prev next links

16 posts by 7 authors in: Forums > CMS Builder
Last Post: June 13, 2011   (RSS)

By Jason - June 8, 2011

Hi Andy,

If you could attach your current .php file, I could take a look and make some suggestions.

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] Additional help needed, was Re: [Damon] page count at bottom with prev next links

By andybarn - June 9, 2011

Hi Jason,

Please see attached php file. The Code Pagination starts at row 285

Thanks for your help.

Andy
Attachments:

listings_001.php 28K

By Jason - June 9, 2011

Hi Andy,

Here is a basic implementation.

It allows you to set a maximum number of pages to display, in this example, we use the number 9. If the page we're outputting is greater than this (ie, when we hit 10), it will output 3 periods (...) and a link to the last page:

<?php
$maxPageNumbers = 9;
?>
<?php foreach (range(1, $listingMetaData['totalPages']) as $page): ?>

<?php if ($page > $maxPageNumbers): ?>
&nbsp;...&nbsp;
<a href= "?<?php echo http_build_query(array_merge($_REQUEST, array( 'page' => $listingsMetaData['totalPages'] ))) ?>"><?php echo $listingsMetaData['totalPages']; ?></a>
<?php break; ?>
<?php endif ?>

<?php if ($page == $current_page): ?>
<strong><?php echo $page; ?></strong>
<?php else: ?>
<a href="?<?php echo http_build_query(array_merge($_REQUEST, array( 'page' => $page ))) ?>" class="whitetextlg"><?php echo $page; ?></a>
<?php endif ?>

<?php endforeach; ?>

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] Additional help needed, was Re: [Damon] page count at bottom with prev next links

By andybarn - June 11, 2011

Hi Jason

Thanks for that, it took me a while to get working but I am there now which is great!

One of the problems I had in case any one else is looking at the code was that you used "listingMetaData" and "listingsMetaData" (with an "s") with your code and it should all be "listingMetaData".

Anyway, once I worked that out, everything worked fine and looks good!

However, it is still not perfect.

If the maximum number of pages is set to 9 and we have 30 pages we get as we would expect :-

1 2 3 4 5 6 7 8 9 ... 30

However if we want to get to page 14 we have to use the "next page" chevron to move through the pages one at a time until we get there . However once on page 14 we still have showing:-

1 2 3 4 5 6 7 8 9 ... 30

Now ideally we would like to have when we are on page 14 (using this forum as an example):-

1 ... 10 11 12 13 14 15 16 17 18 ... 30

That way we can jum forwards and backwards quite easily.

Could you tell me how I would achieve that please. I believe once we have the code for that, it would complete this functionality and be of good use to many people using your software.

Hope you can help.

Thanks
Andy

By Jason - June 13, 2011

Hi Andy,

Here is a post by Chris that should help get you started on this:

http://www.interactivetools.com/forum/gforum.cgi?post=77815#77815

Hope this helps. Please let me know if you run into any issues.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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