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

Multi-Replace variables in Text

 
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
mik3e
Smarty n00b


Joined: 20 Aug 2013
Posts: 4

PostPosted: Tue Aug 20, 2013 2:58 pm    Post subject: Multi-Replace variables in Text Reply with quote

Hi,

I´m using the following form to define text in language files:

Code:
tax_shipping = 'Text with on %s1 variable and another %s2 variable';


In other systems I´m able to use a function which I pass the text and an array of variables to and those are replace one after the other.

I haven´t found such a function for smarty till now. So I´m doing an (ugly) workaround with replace:
Code:
{#tax_shipping#|replace:"%s1":$templateConfig->shipping->shippingCostUrl}


Finally that works but the problem is: What to do if I´ve two or more variables in one text element?

I´m quite sure there is a function in smarty available which can do that for me. Maybe somebody has a hint for me!?

Thanks,
Michael
Back to top
View user's profile Send private message
U.Tews
Administrator


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

PostPosted: Tue Aug 20, 2013 6:01 pm    Post subject: Reply with quote

You can use
Code:
{sprintf(#tax_shipping#,$templateConfig->shipping->shippingCostUrl)}
Back to top
View user's profile Send private message
mik3e
Smarty n00b


Joined: 20 Aug 2013
Posts: 4

PostPosted: Mon Aug 26, 2013 1:47 pm    Post subject: Reply with quote

Great, thanks - I´ll try it...
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