Pagination with multiple categories on list page

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

I use this for pagination on a list page:

<?php if ($portfolioMetaData['prevPage']): ?>
<a href="<?php echo $portfolioMetaData['prevPageLink'] ?>">Previous</a>
<?php else: ?>
Previous
<?php endif ?>

<?php
if (@!$_GET['page']): $current_page = "1";
else: $current_page = $_GET['page'];
endif; ?>
<?php
$startNumber = max($current_page - 6, 1);
$endNumber = min($current_page + 6, $portfolioMetaData['totalPages']);
?>
<?php foreach (range($startNumber,$endNumber) as $page): ?>
<?php if ($page == $current_page): ?>

<?php echo $page; ?>
<?php else: ?><a href="?category=1&page=<?php echo $page; ?>"><?php echo $page; ?></a>
<?php endif ?>
<?php endforeach; ?>

<?php if ($portfolioMetaData['nextPage']): ?>
<a href="<?php echo $portfolioMetaData['nextPageLink'] ?>">Next</a>
<?php else: ?>
Next
<?php endif ?>


everything is working except 1 thing:

How can i make the static category "1" dynamic depending witch category i choose on that list page?

<?php else: ?><a href="?category=1&page=<?php echo $page; ?>"><?php echo $page; ?></a>




Thanks

Re: [Jason] Pagination with multiple categories on list page

Jason,

Check Your mail...


Thanks!

Re: [videopixel] Pagination with multiple categories on list page

By Jason - September 20, 2010

Hi,

If you look at the urls for the next and previous buttons, they store the category in the url string (example:Website). You can take this out of the url and put it in your number links.

<?php else: ?><a href="?category=<?php echo @$_REQUEST['category'];?>&page=<?php echo $page; ?>"><?php echo $page; ?></a>

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 with multiple categories on list page

THANKS Jason!!!

it's working... ;-)