X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Help on if div by 2 (https://forum.x-cart.com/showthread.php?t=1613)

ciava 02-24-2003 02:27 AM

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

funkydunk 02-24-2003 03:24 AM

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}


ciava 02-24-2003 05:34 AM

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}


:?:

funkydunk 02-24-2003 05:53 AM

Yeah you're missing a {/if} after the {/section}

ciava 02-24-2003 11:08 AM

Hi

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

regards

anton

funkydunk 02-24-2003 11:24 AM

My mistake :oops:

{if $smarty.section.cat_num.index is odd}

ciava 02-25-2003 12:47 AM

Thanks for that funkydunk

This has saved me a lot of time.

yet again you prove to be the man

many thanks


All times are GMT -8. The time now is 06:54 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.