Re: Modifier function arguments

Johannes Findeisen <[email protected]>
Newsgroups gmane.comp.php.smarty.devel
Message-ID <[email protected]>
Hello,

i don't know if i understand this right. An example of what i want to do: I 
have a script that is assigning some variables to Smarty. In my case i am 
assigning a variable called CORE_URL. This is the URL of the website which is 
read from a config file. After these variables are assigned i am parsing the 
content against Smarty and with the use of some modifiers. Lets say i have a 
modifier like this:

function smarty_modifier_smile( $message ) {

 $message = str_replace(":-)", "<img style=\"vertical-align: text-bottom;\" 
src=\"" . $smarty->_tpl_vars['CORE_URL'] ."images/smilies/icon_smile.gif\" 
alt=\"smile\" title=\"smile\" />", $message);
 
 return $message;
}

This modifier is replacing ":-)" with a html image tag. This tag needs a 
variable that is assigned to Smarty ($smarty->_tpl_vars['CORE_URL']) to build 
the full path to the image.

I have tried your example but it didn't work for me... I'm getting an error 
like this:

<b>Fatal error</b>: Smarty error: 
[in /data/hanez/www/xcssor/htdocs/themes/xw3/design.ihtml line 56]: [plugin] 
modifier 'smile' is not implemented (core.load_plugins.php, line 36) in 
<b>/data/hanez/www/xcssor/lib/smarty/Smarty.class.php</b> on line 
<b>1088</b><br /> 

Could you help?

Regards

Johannes

On Tuesday 15 February 2005 05:50, boots wrote:
> function MySmarty()
> {
>     $this->Smarty();
>     $this->register_modifier('getvar', array('MySmarty',
> 'modifier_getvar'));
> }
>
> function modifier_getvar($bar, $baz=null)
> {
>     return $this->_tpl_vars($bar);
> }

-- 
Smarty Development Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.