Multiple Categories
3 posts by 2 authors in: Forums > CMS Builder
Last Post: August 6, 2009 (RSS)
By andycal - August 5, 2009
Just had a typical question from a customer.
I've done them a 'menu' style for categories and products under those categories. Works well, but now they've just said "some products could appear in more than one category".
Is it possible to do this?
I've done them a 'menu' style for categories and products under those categories. Works well, but now they've just said "some products could appear in more than one category".
Is it possible to do this?
Re: [andycal] Multiple Categories
By Chris - August 5, 2009 - edited: August 6, 2009
Hi andycal,
Yes, this is certainly possible! I did this by adding a "category" field to my Products section. I set it to Field Type = "List", Display As = "pulldown (multi value)", List Options = "Get options from database (advanced)", Section Tablename = "category", Use this field for option values = "num", Use this field for option labels = "breadcrumb".
Then, in my category detail Viewer, I got a list of products which belong to the selected category with a where clause:
Is this what you were after? Please let me know if you have any questions!
EDIT: changed to use simpler LIKE \t where clause instead of REGEXP [[:<:]]
Yes, this is certainly possible! I did this by adding a "category" field to my Products section. I set it to Field Type = "List", Display As = "pulldown (multi value)", List Options = "Get options from database (advanced)", Section Tablename = "category", Use this field for option values = "num", Use this field for option labels = "breadcrumb".
Then, in my category detail Viewer, I got a list of products which belong to the selected category with a where clause:
list($productsRecords, $productsMetaData) = getRecords(array(
'tableName' => 'products',
'where' => "category LIKE '%\t{$categoryRecord['num']}\t%'",
));
Is this what you were after? Please let me know if you have any questions!
EDIT: changed to use simpler LIKE \t where clause instead of REGEXP [[:<:]]
All the best,
Chris
Chris