D
D
Dmitry2014-04-01 13:04:16
PHP
Dmitry, 2014-04-01 13:04:16

How to make a counter on Smarty?

There is a task. Pull records from the database and display them in order through smarti.
With {foreach} understood. There is one BUT - you need to display a maximum of 4 records at a time.
About:

- первый
  -1
  -2
  -3
  -4
- второй
  -5
  -6
  -7
  -8
...

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
antimind, 2014-04-01
@another_dream

Look towards @iteration. Now smarty is not at hand, but as far as I remember, I did a similar task like this www.smarty.net/docs/en/language.function.foreach.t...

M
Maxim, 2014-04-20
@iru

{foreach $array as $key=>$row}
....
{if $key==4}
Уже 4 ?
{/if}
{/foreach}

R
Roman Hinex, 2014-04-01
@HiNeX

stackoverflow.com/questions/8674831/how-do-you-inc...
{assign var=val value=1}
{assign var=val value=$val+1}
{$val} // Will be 2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question