Previous / Next Problem

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

I'm not sure if I'm doing this the right way, but I have two sections, categories and products and am trying to use previous and next buttons depending on the number of products in the selected category.

So far, I have a call to getRecords for the categories as follows:

list($categoriesRecords, $categoriesMetaData) = getRecords(array(
'tableName' => 'categories',
'where' => whereRecordNumberInUrl(1),
));
$categoriesRecord = @$categoriesRecords[0]; // get first record
The URL on the initial category page looks like this: /collection.php/sanctuary-3/

Then, I have a call to getRecords for the products like this

list($productsRecords, $productsMetaData) = getRecords(array(
'tableName' => 'products',
'where' => 'category like "%\t'.$categoriesRecord['num'].'\t%"',
'perPage' => 20,
'useSeoUrls' => true,
));

When I go to page 2, using the generated next button, the following URL is called
/collection.php/sanctuary-3/page-2/

The problem with this is that the call to whereRecordNumberInUrl() from step 1, finds the '2' from the page part of the URL and displays page 2 of category 2, not of category 3.

I hope this makes sense and am sure I'm probably not handling this in the best way so any help would be appreciated.

Thanks.