View Single Post
  #6  
Old 11-04-2015, 12:32 PM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default Re: Calling additional category as well as main category

I used category 384 as that was the category the first poster used.

You could change:

Code:
categoryid='384'

To:

Code:
categoryid IN ('X','Y','Z')

And update X, Y and Z with your categoryids if you have more.

If you wanted to have a dynamic admin where you could toggle categories off and on as new, I would create a new `is_new` category field in the database (you'd have to update the category add/modify pages as well) and then do a LEFT JOIN on the categories table like so.

Code:
$products[$k]['is_new'] = func_query_first_cell("SELECT pc.categoryid FROM $sql_tbl[products_categories] pc LEFT JOIN $sql_tbl[categories] c ON pc.categoryid=c.categoryid WHERE pc.productid='" . intval($v['productid']) . "' AND c.is_new='Y'") > 0 ? 'Y' : 'N');

Then you could toggle categories off and on in the database.

Or another way, if your new category names were the only ones that started with the word "New" you could do something like:

Code:
$products[$k]['is_new'] = func_query_first_cell("SELECT pc.categoryid FROM $sql_tbl[products_categories] pc LEFT JOIN $sql_tbl[categories] c ON pc.categoryid=c.categoryid WHERE pc.productid='" . intval($v['productid']) . "' AND c.category LIKE 'New %'") > 0 ? 'Y' : 'N');

Jon
Reply With Quote