HELP ! Link in filtered combo page

7 posts by 2 authors in: Forums > CMS Builder
Last Post: December 13, 2012   (RSS)

By Toledoh - December 12, 2012

Hi Guys,

I have a combo page, that displays a search result (to show categories - ie "type")

eg. http://blakemachinery.com.au/products.php?type=25

The list view on the side shows all the items within that category - however, select the item and it links products.php?xxx which then shows all items in the list, not still within the selected "type". It's also not showing the correct product.

I've attached the viewers and the products.php files.


Cheers,

Tim (toledoh.com.au)

By Toledoh - December 12, 2012

Also, how can I link to a specific product? For instance, on the home page (http://blakemachinery.com.au/index.php) I have featured items in the carousel...
Cheers,

Tim (toledoh.com.au)

By gregThomas - December 12, 2012

Hi Tim,

The problem is that the two getRecords functions for the products are using the number in the URL to select a specific num value, and not a type when you view a products details.

I think I've found a way around this, and modified and re-uploaded the files to this post. In the products_005.php I've stored the num value and type value separately in the URL, you should see the change on line 70:

<li<?php if ($isSelected) { print " class='active'"; } ?>><a href="products.php?num=<?php echo $listRecord['num']; ?><?php echo (@$type)? "type=$type" : ''; ?>">

Then in the _globalviewers.php file I've set set search to false for the getRecords functions that pull the products, and added where statements that get the the type and num value separately. I've set it up so that if no num or type value in the URL then they use a default value of 1.

//If there is a num value in the URL, set it to the variable num, if not there isn't use 1 as the defualt value
$num = (@$_REQUEST['num'])? intval($_REQUEST['num']) : '1';

list($productsRecords, $productsMetaData) = getRecords(array(
'tableName' => 'products',
'loadUploads' => true,
'where' => "num = '$num'",
'allowSearch' => false,
'limit' => '1',
));
$detailRecord = @$productsRecords[0]; // get first record

// load list records from 'products'

//If there is a type value in the URL, set it to the variable type, if not there isn't use 1 as the defualt value
$type = (@$_REQUEST['type'])? intval($_REQUEST['type']) : '1';

list($productsRecords, $productsMetaData) = getRecords(array(
'tableName' => 'products',
'where' => "type = '$type'",
'loadUploads' => true,
'allowSearch' => false,
));


Let me know if this doesn't work.

Thanks!
Greg Thomas







PHP Programmer - interactivetools.com

By Toledoh - December 12, 2012

Thanks Greg.

I think there's an error in the global viewers, then product page doesn't load if I use it.

I'll see if I can figure out what... but if you get a chance to review it, that'll be great.
Cheers,

Tim (toledoh.com.au)

By Toledoh - December 12, 2012

OK - pretty much working now (the error was fixed by cut and pasting the file content, rather than using the file itself... strange)

However, the "type" selectors from the home pae, or in the top navigation currently link to something like http://blakemachinery.com.au/products.php?type=25 which used to display the first record - but now, I guess because the $num=1, it's not displaying the detail of the first record.

Is there a way to get $num to equal the first record in that category? if you know what I mean...
Cheers,

Tim (toledoh.com.au)

By Toledoh - December 13, 2012

Brilliant... couldn't be better!

Thanks Greg!
Cheers,

Tim (toledoh.com.au)