Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
associative array in smarty template

 
Post new topic   Reply to topic    Smarty Forum Index -> Tips and Tricks
View previous topic :: View next topic  
Author Message
fmallet
Smarty n00b


Joined: 02 Oct 2011
Posts: 2

PostPosted: Sun Oct 02, 2011 8:02 pm    Post subject: associative array in smarty template Reply with quote

I use Smarty3, and I ve tried several tests and unfortunately, it seems that the code {json_encode(array("message"=>"my message"))} in the smarty template doesn't work, a syntax error appears. The code {json_encode(array("message1","message2"))} works fine. May be the "=>" is not good interpreted by compiler. Thanks in advance if you have a solution. Thank you for your feeback.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 4692
Location: Hamburg / Germany

PostPosted: Sun Oct 02, 2011 8:16 pm    Post subject: Reply with quote

In Smarty arrays are defined by [...] .

See http://www.smarty.net/docs/en/language.syntax.variables.tpl

Code:
{json_encode(["message"=>"my message"])}
Back to top
View user's profile Send private message
fmallet
Smarty n00b


Joined: 02 Oct 2011
Posts: 2

PostPosted: Sun Oct 02, 2011 9:12 pm    Post subject: associative array in smarty template Reply with quote

Thanks .. I ve tested It's work fine thank you for your support. Next time I will read better the documentation before send a post.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Tips and Tricks All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP