![]() |
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} |
that template coding didn;t want to work, i managed to get it working using the following coding instead :
Code:
{if $categories_data[subcat_num].root_category_name == $categories[cat_num].category && $categories_data[subcat_num].category_name != $categories[cat_num].category_name && $categories_data[subcat_num].sub_category_name == $categories_data[subcat_num].root_category_name} |
Thanks for the useful mod :)
|
wasn't working for me
Parse error: parse error, unexpected $ in /hsphere/local/home/reginaha/shrinkbagsandmore.com/shrink-bags/templates_c/customer^categories.tpl on line 79
any suggestions? |
Look at your line # 79 in categories.tpl and see if you are missing a bracket or closing IF tag.
|
my categories.tpl has just 29 lines, do you mean categories.php?
can you see something in the code below? this is line 75 - 90 from my categories.php Code:
$all_categories = $categories_data; thanks for your time, andreas |
Can anyone help adapt this mod for 4.0.0? The variables in the categories.php file are different, and I'm no longer certain what to change ...
|
Quote:
Looking in the settings for 4.0 there is a checkbox in the general settings that will display your subcategories where your categories go.... |
Where is this option in v4.0.4 I am sure its just me but I cannot seem to find this :(
|
Many thanks for this code. It worked out great !!!
Here is the code for those of you whom wish to retain the default style sheet and main category link; Code:
<font class=CategoriesList> |
Always display subcategories in 4.0.x
Here's what worked for me in 4.0.x:
In skin1/customer/categories.tpl: 1. Find the following line: 2. Insert the following code AFTER the line you just found: Code:
{section name=sub_num loop=$allcategories} One, jf |
Thanks for the mod! this is great.
Works great in 3.3.1 I also like the subcategories mod discussed here: http://forum.x-cart.com/viewtopic.php?t=4248 |
Re: Always display subcategories in 4.0.x
Quote:
It doesn't work on 4.0.18 |
Re: subcategory list on home
Hi,
Thanks for your help, it's great. Do you know how I can bold the main categories names? Regards Kurt |
Re: subcategory list on home
Ooops, sorry.
I'd also like to know how I can space the text more, and have thumbnails assigned to each one above or below? I've noticed the main categories are no longer text links. I would like to know how I can make them text links with the same functionality as normal. You click the main category and the subcats will be there, along with any products. Categories such as Pet Electronics do not have sub cats, and the main category is no an active link, which means people cannot see them. Any ideas on how I can achieve this? |
All times are GMT -8. The time now is 12:14 AM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.