开发者

Is it possible to declare a default associative array in Smarty?

开发者 https://www.devze.com 2023-03-31 11:46 出处:网络
In Smarty, I know you can declare a string: {$somevar|default:\'some string\'} or even an array: {$somevar|default:array(\'someval\')}

In Smarty, I know you can declare a string:

{$somevar|default:'some string'}

or even an array:

{$somevar|default:array('someval')}

How do you/Is it possible to set an associative array as a default value? as this doesn't seem to wor开发者_JAVA技巧k:

{$somevar|default:array('default'=>array('subkey'=>'subval'))}

I just tried:

{$somevar|default:array('key'=>'val')}

It's the '=>' smarty doesn't like


I know its probably not the solution you're looking for, but you can always just use the {php} feature. However, I will try a few things and see if I can work the format out.

Just out of interest, why are you trying to do this in the tpl file and not in the calling PHP script?

Edit

From takeing a read, it doesn't seem like it is possible. However, there is a "set" plugin which allows it, see here (bottom example).

0

精彩评论

暂无评论...
验证码 换一张
取 消