开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜