show only specific items based on variable
9 posts by 4 authors in: Forums > CMS Builder
Last Post: December 8, 2009 (RSS)
By IronVictory - June 12, 2008
Re: [IronVictory] show only specific items based on variable
By Dave - June 12, 2008
'where' => ' category="4" ',
Or add values on the end of the url to use the built in search features (see search docs) like you did:
productList.php?category=4
The second method is often the easiest. Are you listing categories on the page that links to the above url? If so you can create a link like this:
productList.php?category=<?php echo $categoryRecord['num']; ?>
Let me know if that works for you.
interactivetools.com
Re: [Dave] show only specific items based on variable
By IronVictory - June 12, 2008
Re: [IronVictory] show only specific items based on variable
By Dave - June 12, 2008
You should be able to do that by just always linking to the page with the category number dynamically added to the end like this:
productList.php?category=2
productList.php?category=44
etc.
Why would the category id change? Do you want to always show items from one category and then optionally show items from another category on the same page?
Are you able to post an url that shows what you want the output to look like? Sorry if I'm not understanding... If you can provide some more details I'll try and help out.
interactivetools.com
Re: [Dave] show only specific items based on variable
By IronVictory - June 12, 2008
Re: [IronVictory] show only specific items based on variable
By Dave - June 12, 2008
productList.php?category=2
Automatically adds this to the where clause 'category = 2'.
productList.php?content_keyword=hello
Automatically adds this to the where clause 'content LIKE "%hello%"'.
There some more documentation on how the searching features work here:
http://www.interactivetools.com/docs/cmsbuilder/viewer_search.html
You only need to manually specify the where clause when you're trying to do something advanced.
Hope that helps!
interactivetools.com
Re: [Dave] show only specific items based on variable
By IronVictory - June 12, 2008
Re: [IronVictory] show only specific items based on variable
By studio-a - December 6, 2009
I have read all the information above and understand the process of using ONE record at the end of the URL so that we can use one php file (say productList.php) for various product category listings. However, I am not clear on the linking pages you mentioned Dave. This also ties in with creating dynamic content to match the URL category (a Page Heading for example).
Since most web pages include a heading at the top of the page content, ( for example - Our Products: Toys) how do we include the dynamic category name (Toys) at the top of the pages so that it matches the dynamic category field within the URL?
It would be nice to use only ONE listing.php file and have the heading match. Sure, we can make separate Listing.php pages, but that means more work. Your help is greatly appreciated.
Thanks,
studio-a
Re: [studio-a] show only specific items based on variable
By Chris - December 8, 2009
Let's say you have two sections: Categories and Products. You could have a page called categoryList.php which has one link per category to productList.php?category=123, where 123 is the category record number.
Inside productList.php, you can load the appropriate category record:
list($categoryRecords, $categoryMetaData) = getRecords(array(
'tableName' => 'category',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$categoryRecord = @$categoryRecords[0]; // get first record
...AND the product records for that category:
list($productsRecords, $productsMetaData) = getRecords(array(
'tableName' => 'products',
));
You can extract the name of the category (e.g. $categoryRecord['title'] which might be "Our Products: Toys") to customize your page's heading, then list the products below.
I hope this helps! Please let me know if you have any questions.
Chris