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?

Re: [petejdg] Using category num in URL

By Chris - September 2, 2009

Hi petejdg,

That's a little more complicated than the original problem. Attached is my solution to your problem. Hit it with ?category=1 and it'll generate links to select the other records. If you call it without a query string, it'll select the first product in your database with the default sort order and choose the category that product is assigned to.

Hope this helps! Please let me know if you have problems getting this set up.
All the best,
Chris
Attachments:

producthybrid.php 3K

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