Retro Posted April 12, 2008 Posted April 12, 2008 I need to set up two boxes displaying different categories, so I'm trying to modify the categories query in categories.php to display only certains categories and do this on the new box. I have found the query but I'm not able to restrict it to only certain categories id such 1, 3, 7... $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '0' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name"); thank you!
Guest Posted April 12, 2008 Posted April 12, 2008 If I understand this correctly, you only want category, say #1 and its subcategories, then use $categories_query = tep_db_query("select c.categories_id, cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '1' and c.categories_id = cd.categories_id and cd.language_id='" . (int)$languages_id ."' order by sort_order, cd.categories_name");
♥FWR Media Posted April 12, 2008 Posted April 12, 2008 The following will work. You have to fill the categories_array() however .. $categories_array = ("'1','3', '7'"); $categories_query = tep_db_query(" SELECT c.categories_id, cd.categories_name, c.parent_id FROM " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd WHERE c.categories_id IN($categories_array) AND c.categories_id = cd.categories_id AND cd.language_id='" . (int)$languages_id ."' order by c.parent_id, sort_order, cd.categories_name"); Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls KissMT Dynamic SEO Meta & Canonical Header Tags KissER Error Handling and Debugging KissIT Image Thumbnailer Security Pro - Querystring protection against hackers ( a KISS contribution ) If you found my post useful please click the "Like This" button to the right. Please only PM me for paid work.
Retro Posted April 12, 2008 Author Posted April 12, 2008 thank you! it's working fine! but... when I try to do the same on a second categories box it doesn't display anything :( I tested the two ways, filtering per parent category or using an array I renamed the function tep_show_category but it doesn't work
♥FWR Media Posted April 12, 2008 Posted April 12, 2008 thank you! it's working fine! but... when I try to do the same on a second categories box it doesn't display anything :( I tested the two ways, filtering per parent category or using an array I renamed the function tep_show_category but it doesn't work As long as it is fed the correct categories_ids that SQL will output them. tep_show_category is an existing function in includes/boxes/categories.php .. choose a more individual/obscure function name function tep_my_unique_categories() or something Ultimate SEO Urls 5 PRO - Multi Language Modern, Powerful SEO Urls KissMT Dynamic SEO Meta & Canonical Header Tags KissER Error Handling and Debugging KissIT Image Thumbnailer Security Pro - Querystring protection against hackers ( a KISS contribution ) If you found my post useful please click the "Like This" button to the right. Please only PM me for paid work.
Retro Posted April 17, 2008 Author Posted April 17, 2008 no way when I create a second box using a query based on another parent category id the result is an empty box
Recommended Posts
Archived
This topic is now archived and is closed to further replies.