Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Multi-Replace variables in Text

 
Post new topic   Reply to topic    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,

Im 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 Im 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 havent found such a function for smarty till now. So Im 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 Ive two or more variables in one text element?

Im 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: 4509
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 - Ill try it...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    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