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

syntax {$foo->function('string'.$var)}

 
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
robert
Smarty Rookie


Joined: 04 Mar 2009
Posts: 13

PostPosted: Mon Oct 26, 2009 4:13 am    Post subject: syntax {$foo->function('string'.$var)} Reply with quote

Hi

I'm calling a function on an object from smarty, and the argument is composed of a concatenated string like so:
{$foo->function('string'.$var)}

This, however doesn't seem to be supported. Is this intentional, and if so, how would the correct way be to go about doing this?
Back to top
View user's profile Send private message
yankee
Smarty Rookie


Joined: 02 Mar 2009
Posts: 31

PostPosted: Mon Oct 26, 2009 12:41 pm    Post subject: Reply with quote

Concat is beeing done using "&" in smarty (not by using ".").
Back to top
View user's profile Send private message
robert
Smarty Rookie


Joined: 04 Mar 2009
Posts: 13

PostPosted: Mon Oct 26, 2009 3:18 pm    Post subject: Reply with quote

Hi

I tried it out and & evaluates to logical AND.

The result is thus:
Code:
$_smarty_tpl->getVariable('foo')->value->function('string' & $_smarty_tpl->getVariable('variable')->value);
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Mon Oct 26, 2009 5:27 pm    Post subject: Reply with quote

Because of several requests the '&' has been redefined for backward compabillity to Smarty2 to the bit logical and operator.

For your case use:

{$foo->function("string`$var`")}
Back to top
View user's profile Send private message
robert
Smarty Rookie


Joined: 04 Mar 2009
Posts: 13

PostPosted: Mon Oct 26, 2009 5:53 pm    Post subject: Reply with quote

Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Smarty 3 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