Using category num in URL

14 posts by 4 authors in: Forums > CMS Builder
Last Post: September 15, 2009   (RSS)

Chris,
that did work. Thanks. I unlocked the password protection so you could see my page:http://www.jdg-siouxlandscale.com/siouxland_scale_products/index.php?category=2

This is something I am trying to wrap my head around. I set up a Categories table. Set up my products table pulling in the db of categories. On this page I am pulling in one random product from the list of products on the left side. On the right side are my products list. What I am trying to do is when you click on a product on the right - to then go to a page exactly like the example, but now have that products info to the left with the same listed category products on the right. So random product now has the requested product info and the product list to the right is the same. Which shouldn't be difficult, but I am lost.
I can't figure out how to add category link to the product links on the right side. This make any sense. Am I going about this the right way?
Thanks, that works great. My only problem now is the navigation system, which wigs out cause I am not passing a category through when clicking on the product from the list on the right. I believe I will need to pass the category number, but that ruins the random product code. Is there quick work around for that?

Re: [petejdg] Using category num in URL

By Chris - September 15, 2009 - edited: September 15, 2009

Hi petejdg,

The code I gave you accepts either ?category=1 or ?product_title_1, and knows to get the category num from the product record if no category num is supplied. Here's the relevant part for reference.

...
// if user did not supply a category, assume they supplied a product num and display that product (also, determine category num for right-side list from that product)
else {
list($selectedProductsRecords, $productsMetaData) = getRecords(array(
'tableName' => 'products',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$selectedProductsRecord = @$selectedProductsRecords[0]; // get first record
assertRecordExists($selectedProductsRecord);
$catNum = $selectedProductsRecord['category'];
}


Which navigation system is breaking? Can you please post an updated copy of your PHP source code?
All the best,
Chris