Re: [SMARTY-DEV] Re: [SMARTY] modifier_string_format in 2.5.0-RC1

From: Date: Thu, 06 Mar 2003 22:07:19 +0000
Subject: Re: [SMARTY-DEV] Re: [SMARTY] modifier_string_format in 2.5.0-RC1
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16  Groups: php.smarty.dev 
Request: Send a blank email to php-smarty-dev+get-905@lists.php.net to get a copy of this message
Monte Ohrt wrote:
Hmm, I'm not the originating author of the modifier structure, but I'll take a guess :-) Function attributes have name/value pairs so an associative array makes sense, and order is not an issue. OTOH, modifier parameters are only values so their order is important. I suppose they could have been passed as an enumerated array of values, that way the second parameter can be the smarty object much the same as functions are. But then your modifier would need to know what each value of $params[0], $params[1], etc. are for without an intuitive name. Monte
I'm going to move this off of the general list. In addition to having to pass the $params and $smarty variable, you also need to pass the string that you're modifying. But on second thought, you don't actually need to pass the $smarty object, because I know of no modifier that works with it, nor can I think of a reason why a modifier would have to work with it, not to mention that right now modifiers don't get the $smarty object anyway. So the way I see it is like this. You pass $string and $params to the modifier function. Logically, $params[0] would be the first argument, $params[1] the second, etc. So to show it visually, it goes like this. Calling the modifier: {"this is a string"|foo:bar1:bar2} function smarty_modifier_foo($string, $params) {
    echo $params[0]    // echos bar1
    echo $params[1]    // echos bar2
} It's not the prettiest method, but it should work, no? Is this something even worth pursuing? Additionally, I suppose that the string_format syntax is going to stay the way it is, much to the shagrin of me :) ~Paul

« previous php.smarty.dev (#905) next »