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

Hiding subcategories when they don't have products

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 03-14-2010, 07:00 PM
 
joannet joannet is offline
 

Senior Member
  
Join Date: Mar 2006
Posts: 105
 

Default Hiding subcategories when they don't have products

I have a number of subcategories that don't have products in them at the moment. On the subcategories page, I would like to be able to hide these subcategories.

When they do have products in them, they should be displayed on the page again.

Here is the subcategories.tpl code:

{*
$Id: subcategories_t.tpl,v 1.6 2008/11/25 15:57:54 max Exp $
vim: set ts=2 sw=2 sts=2 et:
*}
{foreach from=$subcategories item=subcategory}

<div class="subcategories" style="min-width: {$subcat_div_width}px; width: {$subcat_div_width}px; height: {$subcat_div_height}px; min-height: {$subcat_div_height}px;">
{if $subcategory.is_icon}
<a href="home.php?cat={$subcategory.categoryid}"><img src="{$subcategory.icon_url|amp}" alt="{$subcategory.category|escape}" width="{$subcategory.image_x}" height="{$subcategory.image_y}" /></a>
{else}
<img src="{$ImagesDir}/spacer.gif" alt="" width="1" height="{$subcat_img_height}" />
{/if}
<br />
<a href="home.php?cat={$subcategory.categoryid}">{$su bcategory.category|escape}</a><br />
{if $config.Appearance.count_products eq "Y"}
{if $subcategory.product_count}
{$subcategory.product_count} {$lng.lbl_products|lower}
{elseif $subcategory.subcategory_count}
{$subcategory.subcategory_count } {$lng.lbl_categories|lower}
{/if}
{/if}
</div>

{/foreach}
<div class="clearing"></div>

--

Ca anyone please help?

Thanks
__________________
/joannet/
X-Cart version 4.1.9 and above
Reply With Quote
  #2  
Old 03-15-2010, 07:52 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Hiding subcategories when they don't have products

{foreach from=$subcategories item=subcategory}
{if $subcategory.product_count > 0}
<div class="subcategories" style="min-width: {$subcat_div_width}px; width: {$subcat_div_width}px; height: {$subcat_div_height}px; min-height: {$subcat_div_height}px;">
{if $subcategory.is_icon}
<a href="home.php?cat={$subcategory.categoryid}"><img src="{$subcategory.icon_url|amp}" alt="{$subcategory.category|escape}" width="{$subcategory.image_x}" height="{$subcategory.image_y}" /></a>
{else}
<img src="{$ImagesDir}/spacer.gif" alt="" width="1" height="{$subcat_img_height}" />
{/if}
<br />
<a href="home.php?cat={$subcategory.categoryid}">{$su bcategory.category|escape}</a><br />
{if $config.Appearance.count_products eq "Y"}
{if $subcategory.product_count}
{$subcategory.product_count} {$lng.lbl_products|lower}
{elseif $subcategory.subcategory_count}
{$subcategory.subcategory_count } {$lng.lbl_categories|lower}
{/if}
{/if}
</div>
{/if}
{/foreach}
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following 2 users thank cflsystems for this useful post:
am2003 (03-15-2010), julied (08-13-2010)
  #3  
Old 03-15-2010, 09:35 AM
 
joannet joannet is offline
 

Senior Member
  
Join Date: Mar 2006
Posts: 105
 

Default Re: Hiding subcategories when they don't have products

Thanks Steve.
__________________
/joannet/
X-Cart version 4.1.9 and above
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 03:58 PM.

   

 
X-Cart forums © 2001-2020