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 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 gregThomas - December 13, 2012

Hi Tim,

I've rearranged the _globalviewers file slightly and added one new statement:

//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,
));

//If there is a num value in the URL, set it to the variable num, if not then get the first num value from the current menu list.
$num = (@$_REQUEST['num'])? intval($_REQUEST['num']) : intval(@$productsRecords[0]['num']);
//If ther wasn't a value for the menu list, then set the num value to 0.
if($num < 1){ $num = 1; }

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


So now if there isn't a num value in the URL, it tries to set it to the first num value in the $productsRecord array. If $productsRecord array is empty, then the $num variable is set to 1 as a last resort.

The updated version of globalviewers is attached to this post.

Thanks!

Greg
Greg Thomas







PHP Programmer - interactivetools.com
Attachments:

_globalviewers_002.php 3K

By Toledoh - December 13, 2012

Brilliant... couldn't be better!

Thanks Greg!
Cheers,

Tim (toledoh.com.au)