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)
-   -   Numbering in Bestseller (https://forum.x-cart.com/showthread.php?t=39359)

yamiya 04-25-2008 08:32 AM

Numbering in Bestseller
 
What I trying to achieve is to add a simple counter such that it will label bestseller column in such a form.

1. A product
2. B product
3. C product
.
.
.

Anyone knows how to create a simple counter for .tpl file?


{* $Id: bestsellers.tpl,v 1.8.2.1 2006/11/16 13:12:29 max Exp $ *}
{if $bestsellers}
{capture name=bestsellers}
<table cellpadding="0" cellspacing="2">
{foreach from=$bestsellers item=bestseller}
<tr>
{if $config.Bestsellers.bestsellers_thumbnails eq "Y"}
<td width="30">
<a href="product.php?productid={$bestseller.productid }&amp;cat={$cat}&amp;bestseller">{include file="product_thumbnail.tpl" productid=$bestseller.productid image_x=90 product=$bestseller.product}</a>
</td>
{/if}
<td>
<b><a href="product.php?productid={$bestseller.productid }&amp;cat={$cat}&amp;bestseller">{$bestseller.prod uct}</a></b><br />
{$lng.lbl_our_price}: {include file="currency.tpl" value=$bestseller.taxed_price}<br />
</td>
</tr>
{/foreach}
</table>
{/capture}
{include file="dialog.tpl" title=$lng.lbl_bestsellers content=$smarty.capture.bestsellers extra='width="100%"'}
{/if}

kube 04-25-2008 03:47 PM

Re: Numbering in Bestseller
 
hi yamiya,

You can either add a name to the foreach and count the iterations like so...

{foreach from=$bestsellers item=bestseller name=thisloop}
{$smarty.foreach.thisloop.iteration}.
{/foreach}

or you could use {counter}.

Hope this helps.

yamiya 04-25-2008 10:29 PM

Re: Numbering in Bestseller
 
many thanks. it's working seamlessly now :D

http://www.yamiya.com.my

Quote:

Originally Posted by kube
hi yamiya,

You can either add a name to the foreach and count the iterations like so...

{foreach from=$bestsellers item=bestseller name=thisloop}
{$smarty.foreach.thisloop.iteration}.
{/foreach}

or you could use {counter}.

Hope this helps.



All times are GMT -8. The time now is 09:03 PM.

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