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

Subcategory Count?

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 08-25-2011, 06:12 PM
 
Danimal Danimal is offline
 

Senior Member
  
Join Date: Sep 2006
Posts: 134
 

Default Subcategory Count?

X-Cart version 4.3

I am displaying the subcategories only for the currently active parent category using the following code. I can not seem to find how to hide the info if nothing exists. What is happening is the unordered list is creating a space even if the list is empty. I want it to not create the list HTML if there are no sub cats of the parent cat.

I am also leaving in this code I am using what I *thought* should work but has failed me. (see red code)

Code:
{* $Id: categories.tpl,v 1.35 2009/05/12 07:37:15 max Exp $ vim: set ts=2 sw=2 sts=2 et: *} <ul> {foreach from=$categories_menu_list item=c name=categories} <li{interline name=categories}><a href="home.php?cat={$c.categoryid}" title="{$c.category|escape}" {if $cat eq $c.categoryid || $current_category.parentid eq $c.categoryid}class="active_cat"{/if}>{$c.category}</a></li> {if $cat eq $c.categoryid || $current_category.parentid eq $c.categoryid} {if $subcategory.subcategory_count gt 0} <ul> {foreach from=$subcategories item=subcat} <li> <a href="home.php?cat={$subcat.categoryid}" class="sub_cats">{$subcat.category|escape}</a> </li> {/foreach} </ul> {/if} {/if} {/foreach} </ul> {assign var="additional_class" value="menu-categories-list"}
Reply With Quote
  #2  
Old 08-26-2011, 03:13 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Subcategory Count?

{if $subcategory.subcategory_count gt 0}

There is no $subcategory array in this code. replace it with $c. The correct code should be

{if $c.subcategory_count gt 0}.....

Also check in debug window that there is such thing as "subcategory count"
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #3  
Old 08-26-2011, 07:08 AM
 
Danimal Danimal is offline
 

Senior Member
  
Join Date: Sep 2006
Posts: 134
 

Default Re: Subcategory Count?

Thanks Steve! That worked perfectly.

I still have not figured out the debug window though...
__________________
~Dani

For version & mods installed, see post.
Reply With Quote
  #4  
Old 08-27-2011, 07:33 AM
 
Danimal Danimal is offline
 

Senior Member
  
Join Date: Sep 2006
Posts: 134
 

Default Re: Subcategory Count?

I found one problem. When I click into a subcategory then go to a product whose main category is the sub-category, the sub-categories disappear.

Here are breadcrumbs:

Code:
Home > Parent Cat > Sub Cat > Product Title

The side navigation only shows the list of parent categories.
__________________
~Dani

For version & mods installed, see post.
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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 07:22 AM.

   

 
X-Cart forums © 2001-2020