CarlJames Posted December 14, 2012 Share Posted December 14, 2012 I am looking for a way to show on the front page, a list of all the subcategories for one particular category (e.g. Category with ID 35). Any idea how to go about this in the index.tpl file? Link to comment Share on other sites More sharing options...
NemoPS Posted December 15, 2012 Share Posted December 15, 2012 Hi, You can't do it directly from the tpl. You have to edit a module's php file, and assign the variables. If you want, you can also try to edit the categoryController, or use an override fo it. But it any case, you'd need something like this (just an example, more stuff is needed in the query) $current_category_id = Tools::getValue('id_category'); $subcategories = Db::getInstance()->ExecuteS(' SELECT c.id_category, cl.name, cl.link_rewrite FROM '. _DB_PREFIX_. 'category c LEFT JOIN '. _DB_PREFIX_. 'category_lang cl ON (c.id_category = cl.id_category) WHERE c.id_parent = '. (int)$current_category_id.' '); That should do it. Of course, you'd need to add the result to the template afterwards Cheers! 1 Link to comment Share on other sites More sharing options...
kiranrathod Posted March 22, 2013 Share Posted March 22, 2013 Hi, You can't do it directly from the tpl. You have to edit a module's php file, and assign the variables. If you want, you can also try to edit the categoryController, or use an override fo it. But it any case, you'd need something like this (just an example, more stuff is needed in the query) $current_category_id = Tools::getValue('id_category'); $subcategories = Db::getInstance()->ExecuteS(' SELECT c.id_category, cl.name, cl.link_rewrite FROM '. _DB_PREFIX_. 'category c LEFT JOIN '. _DB_PREFIX_. 'category_lang cl ON (c.id_category = cl.id_category) WHERE c.id_parent = '. (int)$current_category_id.' '); That should do it. Of course, you'd need to add the result to the template afterwards Cheers! i have same query... i need to get category(level 0th) id from subcategory (next higher level)id so how to get it can u insist me. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now