Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

subcategory list on home

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 04-09-2004, 09:01 AM
 
luoifong luoifong is offline
 

Member
  
Join Date: Jun 2003
Location: Colorado
Posts: 16
 

Default 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!
Reply With Quote
  #2  
Old 04-20-2004, 01:41 AM
 
mcopeland mcopeland is offline
 

Advanced Member
  
Join Date: Apr 2003
Location: Paris, France
Posts: 40
 

Default

Hi,

Have you ever figured this out? Did you progress on the matter?

Please advise.

Thanks.
Reply With Quote
  #3  
Old 04-20-2004, 08:25 AM
  joshf's Avatar 
joshf joshf is offline
 

Advanced Member
  
Join Date: Jul 2003
Posts: 97
 

Default

Quote:
Originally Posted by mcopeland
Have you ever figured this out? Did you progress on the matter?

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!
__________________
joshf | X-Cart Portfolio
Currently: http://nightowlpapergoods.com | http://pinkolive.com
Reply With Quote
  #4  
Old 04-20-2004, 10:10 AM
 
2getInk 2getInk is offline
 

Member
  
Join Date: Apr 2004
Posts: 12
 

Default

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.
Reply With Quote
  #5  
Old 04-20-2004, 10:52 AM
 
2getInk 2getInk is offline
 

Member
  
Join Date: Apr 2004
Posts: 12
 

Default

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} {$categories[cat_num].category_name} <span class="sub" id="{$categories[cat_num].categoryid}"> {section name=subcat_num loop=$categories_data} {if $categories_data[subcat_num].root_category_name == $categories[cat_num].category && $categories_data[subcat_num].category_name != $categories[cat_num].category_name} <a href="home.php?cat={$categories_data[subcat_num].categoryid}"> -{$categories_data[subcat_num].category_name}</A> {/if} {/section} </span> {/section}


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);
Reply With Quote
  #6  
Old 04-20-2004, 12:15 PM
  joshf's Avatar 
joshf joshf is offline
 

Advanced Member
  
Join Date: Jul 2003
Posts: 97
 

Default

Works over here.... Thanks for the post.
__________________
joshf | X-Cart Portfolio
Currently: http://nightowlpapergoods.com | http://pinkolive.com
Reply With Quote
  #7  
Old 04-20-2004, 09:28 PM
 
luoifong luoifong is offline
 

Member
  
Join Date: Jun 2003
Location: Colorado
Posts: 16
 

Default

I had finally gone the route of hard coding the links...I'll try out this code.

Thanks for the post 2getInk!
Reply With Quote
  #8  
Old 04-29-2004, 01:37 AM
 
2getInk 2getInk is offline
 

Member
  
Join Date: Apr 2004
Posts: 12
 

Default

Glad to help.
Reply With Quote
  #9  
Old 05-05-2004, 06:30 AM
  carlisleglass's Avatar 
carlisleglass carlisleglass is offline
 

eXpert
  
Join Date: Aug 2003
Location: Carlisle, UK
Posts: 316
 

Default

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
__________________
Darren Kierman
Carlisle Glass (http://www.carlisleglass.co.uk/)
... running X-Cart Gold 4.4.5 [unix]
Reply With Quote
  #10  
Old 05-05-2004, 07:42 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

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.

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}
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 12:10 PM.

   

 
X-Cart forums © 2001-2020