Embeddign php in smarty templates

Hello I want to know how can I embed php tag and php variables, loops etc in smarty tempaltes?
I have seen some examples to embed if condition lie


[{if $id}]
[{/if}]

But how can I put loops, arrays, built in functions like echo , print_r, etc in ths tempalte. i have seen an example from smarty site like this


{php}
{/php}

But When I embeded the for loop in it it displays my code as it is


{php}
for($i=0;$i<10;$i++)
echo $i;
{/php}

Please guide me how can I accomplish this job?
Regards,
Awias Qarni

smarty can do almost every thing php might be used for (in frontend)

if you still want to use php in templates:
as you surely have noticed, OXID uses a non-standard smarty tag-wrapping: [B][{ [/B]smarty [B]}][/B] instead of [B]{[/B] smarty [B]}[/B]
so you need to try

 [{php}] .... [{/php}]

and “switch on” php in templates under
shop => settings => system

[QUOTE=vanilla thunder;84629]smarty can do almost every thing php might be used for (in frontend)

if you still want to use php in templates:
as you surely have noticed, OXID uses a non-standard smarty tag-wrapping: [B][{ [/B]smarty [B]}][/B] instead of [B]{[/B] smarty [B]}[/B]
so you need to try

 [{php}] .... [{/php}]

and “switch on” php in templates under
shop => settings => system[/QUOTE]
Thanks dudefor your response. First I haven’t found any option to “switch on” php in my system. I am using community edition 4.5.6_40808 .
Secondly I have tried [{php}] and it started to work. Now I want to ask if I have to do all these in smarty then how can I? For example I have an array and I want to traverse through array using for loop then how can I do this with smarty?

the “php-on-switch” is one of the last settings, i have no idea what is it called in english, cause my backend is in german, but there is a dropdown where you can choose what should happen to the php code, e.g. nothing, run it or just print it like text.

for traversing arrays you can use foreach or section, just have a loot at the smarty documentation:
http://www.smarty.net/documentation
oxid runs smarty 2, you can use avery function you will find there but even with [{ }].

probably you will neet to transfer your array to smarty if you create it somewhere in php, it works with
$smarty->assign();

you can also look into the classes and templates of oxid and see how some things work.