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

Help on if div by 2

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 02-24-2003, 02:27 AM
 
ciava ciava is offline
 

Advanced Member
  
Join Date: Nov 2002
Location: UK
Posts: 56
 

Default Help on if div by 2

Hi All

im having a few glitches with dividing the subcategory section into 2 per row.

i have done the following code, but when the subcategories, template loads, instead of dividing the subcategories by 2 per row, its putting them all in one line.



Code:
<table width="100%" border=0 cellspacing=5> {section name=cat_num loop=$subcategories} {if smarty.section.cat_num.index is div by 2} <tr> { if %cat_num.first% } {/if}{/if}<td align=left nowrap width=20%> <font class="TableCenterSubCategoryListTitleBlue">{ $subcategories[cat_num].category|escape }</font></td><td align=left width="80%"> <font class="TableCenterSubCategoryListQuantityBlue">({ $subcategories[cat_num].product_count })</font></td> { if %cat_num.last% } </tr> {/if} {/section} </table> {/if}

If anyone could shed some light as where im going wrong, as i think i just have one of the ending if staments in the wrong place.

Many thanks
Reply With Quote
  #2  
Old 02-24-2003, 03:24 AM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

Almost right...

Code:
{section name=cat_num loop=$subcategories} { if %cat_num.first% } <table width="100%" border=0 cellspacing=5> <tr> {/if} {if $smarty.section.cat_num.index is odd} </tr> <tr> {/if} <td align=left nowrap width=20%> <font class="TableCenterSubCategoryListTitleBlue">{ $subcategories[cat_num].category|escape }</font></td><td align=left width="80%"> <font class="TableCenterSubCategoryListQuantityBlue">({ $subcategories[cat_num].product_count })</font></td> { if %cat_num.last% } </tr> </table> {/if} {/section}
__________________
ex x-cart guru
Reply With Quote
  #3  
Old 02-24-2003, 05:34 AM
 
ciava ciava is offline
 

Advanced Member
  
Join Date: Nov 2002
Location: UK
Posts: 56
 

Default

Hi funkydunk

thanks for the quick response, i have tried implementing your code, and i came up with an error of
Quote:
Parse error: parse error in /home/chava_1/savatrader-www/products/templates_c/%%103/%%1035601712/subcategories.tpl.php on line 87

this is what my full source code looks like with your additions

Quote:


{* $Id: subcategories.tpl,v 1.21 2002/09/10 12:36:34 zorg Exp $ *}
{ include file="location.tpl" }
{if $active_modules.Bestsellers ne "" and $config.Modules.bestsellers_menu ne "Y"}



{include file="modules/Bestsellers/bestsellers.tpl"}
{/if}



{ include file="customer/main/navigation.tpl" }
{if ($page eq "")||($page eq "1")}{$current_category.description|regex_replace: "/[\n]/":"
"}

{/if}
{capture name=dialog}
{if $subcategories}
[img]../icon.php?categoryid={$cat}[/img]
{/if}
{if $current_category.categoryid eq 130}
{ include file="customer/main/shops.tpl" }
{else}
{section name=cat_num loop=$subcategories}
{ if %cat_num.first% }
<table width="100%" border=0 cellspacing=5>
<tr>
{/if}
{if smarty.section.cat_num.index is odd}
</tr>
<tr>
{/if}
<td align=left nowrap width=20%>
<font class="TableCenterSubCategoryListTitleBlue">{ $subcategories[cat_num].category|escape }</font></td><td align=left width="80%">
<font class="TableCenterSubCategoryListQuantityBlue">({ $subcategories[cat_num].product_count })</font></td>
{ if %cat_num.last% }
</tr>
</table>
{/if}
{/section}
{if $subcategories ne "" and $products ne ""}
<hr size=1 noshade>
{/if}
{include file="customer/main/products.tpl" products=$products}
{if $products eq "" and $subcategories eq ""}
{$lng.txt_no_products_in_cat}
{/if}
{/capture}
{include file="dialog.tpl" title=$current_category.category|regex_replace:"/.*\//":"" content=$smarty.capture.dialog extra="width=100%"}
{if $products eq ""}
{if $f_products ne ""}



{include file="customer/main/featured.tpl"}
{/if}
{/if}

Reply With Quote
  #4  
Old 02-24-2003, 05:53 AM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

Yeah you're missing a {/if} after the {/section}
__________________
ex x-cart guru
Reply With Quote
  #5  
Old 02-24-2003, 11:08 AM
 
ciava ciava is offline
 

Advanced Member
  
Join Date: Nov 2002
Location: UK
Posts: 56
 

Default

Hi

i've tried adding the last {/if} and i still get the same error is it something else i've overlooked

regards

anton
Reply With Quote
  #6  
Old 02-24-2003, 11:24 AM
 
funkydunk funkydunk is offline
 

X-Man
  
Join Date: Oct 2002
Location: Cambridge, UK
Posts: 2,210
 

Default

My mistake

{if $smarty.section.cat_num.index is odd}
__________________
ex x-cart guru
Reply With Quote
  #7  
Old 02-25-2003, 12:47 AM
 
ciava ciava is offline
 

Advanced Member
  
Join Date: Nov 2002
Location: UK
Posts: 56
 

Default

Thanks for that funkydunk

This has saved me a lot of time.

yet again you prove to be the man

many thanks
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


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

   

 
X-Cart forums © 2001-2020