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

String_format

 
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 -> Smarty Development
View previous topic :: View next topic  
Author Message
log1st
Smarty n00b


Joined: 03 Oct 2014
Posts: 2

PostPosted: Fri Oct 03, 2014 11:47 pm    Post subject: String_format Reply with quote

Is it possible to set more than one parameter in string_format?

Config:
join_form_login_hint="From %1n to %2n symbols. Available symbols: %3n"

Template:
{2,3,A-z|string_format:{#join_form_login_hint#}}
Back to top
View user's profile Send private message
log1st
Smarty n00b


Joined: 03 Oct 2014
Posts: 2

PostPosted: Sat Oct 04, 2014 12:54 am    Post subject: Solved Reply with quote

Solved this problem via editing file smarty/plugins/modifiercompiler.string_format.php:

Code:

function smarty_modifiercompiler_string_format($params, $compiler)
{
   $more=explode('###',$params[0]);
   if(count($more)>1) {
      $parames=implode('\',\'',$more).'';
   }   else {
      $parames=$params[0];
   }
   return 'sprintf(' . $params[1] . ',' . $parames . ')';
}


Then add string like this in template file:

Code:

{'2###12###A-z'|string_format:"{#join_form_login_hint#}"}
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 -> Smarty Development 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