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

Categories Menu - Showing Subcategories

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 06-18-2003, 11:23 AM
 
inVINCEible inVINCEible is offline
 

Member
  
Join Date: Mar 2003
Location: California, USA
Posts: 21
 

Default Categories Menu - Showing Subcategories

What would I need to do to get the subcategories to show for the category that the user is currently in?

For example, on the main page, the category menu would show:

- Cat A
- Cat B
- Cat C
- Cat D

However, if you click on Cat A, or go to a product that is in Cat A, the menu would show:

- Cat A
--- Sub Cat 1
--- Sub Cat 2
--- Sub Cat 3
- Cat B
- Cat C
- Cat D

Any help would be greatly appreciated. Thanks!
Reply With Quote
  #2  
Old 06-18-2003, 11:47 AM
 
inVINCEible inVINCEible is offline
 

Member
  
Join Date: Mar 2003
Location: California, USA
Posts: 21
 

Default

So far.. I have..

Code:
{if $config.General.root_categories eq "Y"} {section name=cat_num loop=$categories} { $categories[cat_num].category|escape } {if $cat eq $categories[cat_num].categoryid} {section name=subcat_num loop=$subcategories} { $subcategories[cat_num].category|escape } {/section} {/if} {/section} {/if}

..but it's outputting the same subcategory.

So for Cat A, instead of getting:

- Cat A
--- Sub Cat 1
--- Sub Cat 2
--- Sub Cat 3
- Cat B
- Cat C
- Cat D

...i get

- Cat A
--- Sub Cat 1
--- Sub Cat 1
--- Sub Cat 1
- Cat B
- Cat C
- Cat D
Reply With Quote
  #3  
Old 06-19-2003, 11:43 AM
 
brgreene brgreene is offline
 

Advanced Member
  
Join Date: Oct 2002
Posts: 70
 

Default

I would like to display my menus this way also. Did you ever figure it out.
__________________
Brian
X-Cart 4.0.18
Reply With Quote
  #4  
Old 06-19-2003, 12:28 PM
  kpayne's Avatar 
kpayne kpayne is offline
 

X-Adept
  
Join Date: Dec 2002
Location: Firetanksoftware.com
Posts: 469
 

Default

Try this:

Code:
{section name=cat_num loop=$categories} { $categories[cat_num].category|escape } {if $cat eq $categories[cat_num].categoryid} {section name=subcat_num loop=$subcategories} { $subcategories[subcat_num].category|escape } {/section} {/if} {/section}

You didn't have the index in the inner loop set correctly (cat_num vs. subcat_num). I also added "
" tags to make it display properly.

Hope this helps!

--Kurt
Reply With Quote
  #5  
Old 06-19-2003, 01:39 PM
 
inVINCEible inVINCEible is offline
 

Member
  
Join Date: Mar 2003
Location: California, USA
Posts: 21
 

Default

thanks! it works like a charm. I didnt have the
in there because the code sniplet i posted was a stripped down version of what im using... i have my menu setup in tables.

http://www.aheadgames.com/cart/customer/home.php

Here's the /customer/categories.tpl I'm using if anyone wants to do anything similar.. you might have to change things a bit to work with your cart.
Code:
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="250"> {if $config.General.root_categories eq "Y"} {section name=cat_num loop=$categories} <tr> <td height="20" background="../../images/categorybg.gif"> <p align="left" class="menutext">{ $categories[cat_num].category|escape }</td> </tr> {if $cat eq $categories[cat_num].categoryid} {section name=subcat_num loop=$subcategories} <tr> <td height="20" background="../../images/categorybg.gif" class="menutext">{ $subcategories[subcat_num].category|escape }</td> </tr> {/section} {/if} {/section} {/if} <tr> <td height="20" background="../../images/categorybg.gif" class="menutext">{$lng.lbl_gift_certificates}</td> </tr> <tr> <td background="../../images/categorybgshadow.gif" height="18"> <font face="Arial" size="1"></font></td> </tr> </table>
Reply With Quote
  #6  
Old 06-19-2003, 01:51 PM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

Nice mod that, moved to custom templates
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
  #7  
Old 06-22-2003, 01:04 PM
 
brgreene brgreene is offline
 

Advanced Member
  
Join Date: Oct 2002
Posts: 70
 

Default

inVINCEible,

How did you get the sub-categories to stay after a person clicks them. Did you have to make any other modifications?

The categories and sub-categories are displaying correctly but if you click a sub-Categorie only the main categories are showing. The Sub-Categories disappear.




Code:
<TABLE border=0 cellPadding=2 cellSpacing=0 width=100%> <tr> <td colspan="2" align="center" class="VertMenuTitle">[img]{$ImagesDir}/category.gif[/img]</td> </tr> {if $config.General.root_categories eq "Y"} {section name=cat_num loop=$categories} <tr> <td height="15" valign="middle" class="VertMenuBox"> <p align="left"><a href="home.php?cat={ $categories[cat_num].categoryid }"> { $categories[cat_num].category|escape }</a></td> </tr> {if $cat eq $categories[cat_num].categoryid} {section name=subcat_num loop=$subcategories} <tr> <td height="15" valign="middle" class="VertSubMenuBox">-<a href="home.php?cat={ $subcategories[subcat_num].categoryid }">{ $subcategories[subcat_num].category|escape }</a></td> </tr> {/section} {/if} {/section} {/if} </table>
__________________
Brian
X-Cart 4.0.18
Reply With Quote
  #8  
Old 06-24-2003, 07:02 AM
 
blagarde blagarde is offline
 

Member
  
Join Date: Jun 2003
Posts: 28
 

Default

This is extremely cool and almost exactly what I am in need of right now! But Brian has a really good question. Additionally, I'd like to figure out a way to have the first main category initially opened by default, showing its sub-categories when a person first goes to the site. That way it will be more obvious to less experienced users that all these menus open to reveal more.
Reply With Quote
  #9  
Old 06-25-2003, 08:09 AM
 
ajaycg ajaycg is offline
 

Newbie
  
Join Date: Jan 2003
Posts: 8
 

Default



Hey inVINCEible,

Ditto to the two above, fantastic mod.. must admit, the ahead games site looks awesome..

Got a question... same as Brian... How did you get the sub-categories to stay after a person clicks them. would love to know how you did it!

Cheers man..

Aj
Reply With Quote
  #10  
Old 06-28-2003, 03:58 PM
 
barabbas barabbas is offline
 

Advanced Member
  
Join Date: Feb 2003
Posts: 52
 

Default

http://www.below-0.net

is there any chance you can make it more like that? by this i mean, not open up a new page aswell as revieling the lst of subcats
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 06:09 PM.

   

 
X-Cart forums © 2001-2020