• Register
Plug-in Tutorial Build an EC-CUBE plug-in

Top Commentators

114

1

EC Mike

SHOGUNSHOGUN

32

2

hrbabu

SAMURAISAMURAI

29

3

Sumant Jha

SAMURAISAMURAI

29

4

justcubed

SAMURAISAMURAI

21

5

Ashok Kafle

SAMURAISAMURAI

21

6

shahith

SAMURAISAMURAI

14

7

Jeemusu

KABUKIKABUKI

14

8

Yangsin

KABUKIKABUKI

9

9

Zaw Hlaing Bwar

GEISYAGEISYA

8

10

Fei Liu

GEISYAGEISYA

Ranking Key

  • FUJISANFUJISAN1,000+ posts
  • SAKURASAKURA500+ posts
  • SHOGUNSHOGUN100+ posts
  • NINJYANINJYA50+ posts
  • SAMURAISAMURAI20+ posts
  • KABUKIKABUKI10+ posts
  • GEISYAGEISYALess than 10 posts

PHP code in tpl smarty file

+3 votes

Will you please tell me if its possible to write php code in tpl smarty file?

Sorry to ask this How to use for loop in smarty file?

For eg:

{for $foo=1 to 5}

    {$foo}

 

{/for} is not shown result in tpl file?
asked 2013-05-16 by shahith (850 points) SAMURAISAMURAI
edited 2013-05-16 by shahith

1 Answer

0 votes

Shahith,

Smarty uses its own syntax. For example in the backend, if you have an item key array, you can display it in the template like so:

 {foreach key=key item=item from=$backendarray}

    {$key}: {$item}<br />

  {/foreach}

 

I hope that makes a bit more sense now.

Smarty has a great guide you can also refer to if you have more questions:

http://www.smarty.net/docsv2/en/language.function.foreach

 

Thank you,

Mike

 

answered 2013-05-16 by EC Mike (6,360 points) SHOGUNSHOGUN
Michael,
Thank you very much for your answer.
...