简体   繁体   中英

Passing a smarty array value to php object…?

In Smarty: is it possible to call a PHP function (from the controller class) inside the template? there is explained, how to call class methods out of template files.

You nee to assign the object like

$smarty->assign('a', new Controller);

and you can use it like

{$a->foo(5)}

But what, if I want to pass a smarty array value as parameter? It should be something like this:

{foreach from=$dataset item=data}
   {$a->foo($data.id)}
{/foreach}

for sure, this won't work. But how can this issue be handled?

Chapter 15. Advanced Features

This is what you need?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM