Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

print value of php function in a Smarty template

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
sempere
Smarty n00b


Joined: 17 Jul 2009
Posts: 3

PostPosted: Sun Jul 19, 2009 11:44 am    Post subject: print value of php function in a Smarty template Reply with quote

Hi!

I have a php function that returns a string, and in the template, on one hand I would like to compare this value and on the other, I would like to print it.

I can do the compare ( { if myfunction() == "" } ), but I can't find how print that value. I tried with {$myfunction()} and {myfunction()}, but with no result... They raise and Smarty error...

Can somebody give me a hand?

Thanks!
Back to top
View user's profile Send private message
alokin
Smarty Regular


Joined: 14 Apr 2009
Posts: 96
Location: Belgrade, Serbia

PostPosted: Sun Jul 19, 2009 12:45 pm    Post subject: Reply with quote

When you say "function", do you mean Smarty plugin? It's kinda unusual to call PHP function in your template. You should evaluate that function in your PHP code, and then assign return value to Smarty.

But if you're trying to call some custom plugin function inside your template, you should simply do that this way: {someFunction}, which will output its return value.
_________________
www.nikolaposa.in.rs
Back to top
View user's profile Send private message
sempere
Smarty n00b


Joined: 17 Jul 2009
Posts: 3

PostPosted: Sun Jul 19, 2009 3:10 pm    Post subject: Reply with quote

I tried it so, but it continues raising a fatal error: unrecognized tab myfunction($foo).
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General 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