 |

IronVictory
User
Jun 12, 2008, 8:36 AM
Post #1 of 7
(487 views)
Shortcut
|
|
show only specific items based on variable
|
Can't Post
|
|
I am using a link similar to this to show only items in a category: productList.php?category=4. How do i show only items that are in this category keeping in mind that the category variable changes. Can I put a variable in a 'where' clause?
|
|
|  |
 |

Dave
Staff
/ Moderator

Jun 12, 2008, 10:43 AM
Post #2 of 7
(484 views)
Shortcut
|
|
Re: [IronVictory] show only specific items based on variable
[In reply to]
|
Can't Post
|
|
There are two ways to limit the results shown on the page. You can add 'where' clause such as: '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. Dave Edis - Senior Developer interactivetools.com
|
|
|  |
 |

IronVictory
User
Jun 12, 2008, 11:54 AM
Post #3 of 7
(475 views)
Shortcut
|
|
Re: [Dave] show only specific items based on variable
[In reply to]
|
Can't Post
|
|
hi Dave,I guess my main problem is how do I show only items from the specific category on the list page if the category id changes? I want to use one productList.php page, not separate pages for each category.
|
|
|  |
 |

Dave
Staff
/ Moderator

Jun 12, 2008, 12:24 PM
Post #4 of 7
(472 views)
Shortcut
|
|
Re: [IronVictory] show only specific items based on variable
[In reply to]
|
Can't Post
|
|
Let me make sure I understand correctly. Let me know if this right. You have a single product list page (productList.php) and you want it to show products from only a single category at a time? Is that right? 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. Dave Edis - Senior Developer interactivetools.com
|
|
|  |
 |

IronVictory
User
Jun 12, 2008, 1:34 PM
Post #5 of 7
(465 views)
Shortcut
|
|
Re: [Dave] show only specific items based on variable
[In reply to]
|
Can't Post
|
|
Yes you are correct. The category id would change as you have it productList.php?category=2, productList.php?category=44, etc. I just meant it will change depending on which category I want to show. My problem is how do I show only category 2 on the productList.php page? I need to be able to filter the records on the productList.php page to only show category id of 2. A MySQL 'where' => 'category="2"' won't work as the category id may be 44, etc. Do you see what I mean? I need to get the id from the URL then filter the records, so I would need something like this: 'where' => 'category="$record[category]"'. Hopefully that is a little clearer!
|
|
|  |
 |

Dave
Staff
/ Moderator

Jun 12, 2008, 1:41 PM
Post #6 of 7
(463 views)
Shortcut
|
|
Re: [IronVictory] show only specific items based on variable
[In reply to]
|
Can't Post
|
|
It does that automatically by default. If you put a fieldname from the CMS in the url with a value it will add that to the where clause. For example, if you have a field called 'category' then this url: 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! Dave Edis - Senior Developer interactivetools.com
|
|
|  |
 |

IronVictory
User
Jun 12, 2008, 2:27 PM
Post #7 of 7
(454 views)
Shortcut
|
|
Re: [Dave] show only specific items based on variable
[In reply to]
|
Can't Post
|
|
Boy does that ever help. Thank you!
|
|
|  |
|