|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
TiXav Smarty n00b
Joined: 08 Feb 2012 Posts: 1
|
Posted: Wed Feb 08, 2012 2:01 pm Post subject: Assign in PHP |
|
|
Hello,
In the file "product-list.tpl",
in the loop "{foreach from=$products item=product name=products}",
I want to get in tags "{php} {/php}" the variable "$product->id" that I will use in a php function that I created.
Do you have a solution?
Thanks |
|
Back to top |
|
mohrt Administrator
Joined: 16 Apr 2003 Posts: 7368 Location: Lincoln Nebraska, USA
|
Posted: Thu Feb 09, 2012 4:28 pm Post subject: |
|
|
Write a plugin, and use that in the template.
Code: | {foreach from=$products item=product name=products}
{myfunction id=$product->id}
{/foreach} |
Otherwise you can use in {php} tags (turn on backward compatability):
Code: | $product = $smarty->getTemplateVar("product");
echo $product->id; |
in PHP 2.x it is $smarty->get_template_var() |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|