![]() |
subcategory list on home
I would like to list different subcategory groups on the home page. I know customer/categories.tpl lists the top level categories. customer/main/subcategories.tpl displays a particular subcategory, but that is coming from a page (the home page for example) that sends along a category id.
So on the home page (which hasn't received a particular category id, and I would want numerous subcategory group listings anyway) I'm not sure how to list different subcategory groups. Anyone know how to do this...or do I have to hard code in the subcategory links into the home page? Thanks! |
Hi,
Have you ever figured this out? Did you progress on the matter? Please advise. Thanks. |
Quote:
Hey Melcom, Coincidence that we both happened across this topic on the same day. I'm also looking for a solution to this... If anyone has any ideas, please post it here! |
Hey guys,
I am also looking for the same solution. Take a look at categories of http://www.savatrader.com/shop/customer/home.php. If this is possible, then the solution we are looking for should be simple. I will search through the forum and let everyone know if I find something useful. Thanks. |
Hi,
I have found a code by boomer which was for the kind of thing done on http://www.savatrader.com/shop/customer/home.php. I have modified the code to make it suitable for us. Hope it helps everyone. I have tested it on x-cart version: 3.4.12 Edit skin1/customer/categories.tpl: Code:
{section name=cat_num loop=$categories} Edit include/categories.php: Comment out the line (just add a # in front of it): Code:
$categories_data = func_query("select $sql_tbl[categories].*, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', -1) as category_name from $sql_tbl[categories] ".($current_area=="C"?"where $sql_tbl[categories].avail='Y' $membership_condition ":"")." group by $sql_tbl[categories].categoryid order by ".($current_area=="C" ? "order_by" : "category")); and add the following underneath it: Code:
$categories_data = func_query("select $sql_tbl[categories].*, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', -1) as category_name, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', 1) as root_category_name from $sql_tbl[categories] ".($current_area=="C"?"where $sql_tbl[categories].avail='Y' $membership_condition ":"")." group by $sql_tbl[categories].categoryid order by ".($current_area=="C" ? "order_by" : "category")); Then go down to the bottom of the file where the "Assign Smarty variables" comment is, underneath it add: Code:
$smarty->assign("categories_data",$categories_data); |
Works over here.... Thanks for the post.
|
I had finally gone the route of hard coding the links...I'll try out this code.
Thanks for the post 2getInk! |
Glad to help. :wink:
|
HELP !!!
This coding works a treat but it displays all sub categories within a main categories ... how do i change the coding so it only shows the first level sub categories. I know it has something to do with checking to see if the categories name has a second / in it, but dont know php that way to sort it |
Code:
$categories_data = func_query("select $sql_tbl[categories].*, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', -1) as category_name, SUBSTRING_INDEX($sql_tbl[categories].category, '\/', 1) as root_category_name, SUBSTRING_INDEX(SUBSTRING_INDEX($sql_tbl[categories].category, '\/', -2),'\/',1) as sub_category_name from $sql_tbl[categories] ".($current_area=="C"?"where $sql_tbl[categories].avail='Y' $membership_condition ":"")." group by $sql_tbl[categories].categoryid order by ".($current_area=="C" ? "order_by" : "category")); This will get the sub_category_name as well. :wink: template code for the 1st tier from root: Code:
{if $categories_data[subcat_num].root_category_name == $categories_data[cat_num].category && $categories_data[subcat_num].category_name != $categories_data[cat_num].category_name && $categories_data[subcat_num].sub_category_name == $categories_data[subcat_num].root_category_name} |
All times are GMT -8. The time now is 12:16 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.