Re: [SMARTY] assign filter

From: Date: Tue, 27 Aug 2002 09:55:40 +0000
Subject: Re: [SMARTY] assign filter
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-5835@lists.php.net to get a copy of this message
On 27 Aug 2002 at 18:28, Peter Kmet wrote: > Hello is it possible to use some sort of filter to every data assigned to > template? i need to call stripslashes function to every string that i send > to template using $tpl->assign() > > is there another way then modify smarty.class.php? > > (I can't use magic_quotes) > > Thanks Peter You can: - modify smarty.class.php (d'oh!) - implement a function doing the job: <?php function stripslash_assign(&$smarty, $var, $value) { return $smarty->assign($var, stripslashes($value)); } //$tpl->assign('x', 'y'); stripslash_assign($tpl, 'x', 'y'); ?> - use your own smarty class (extending Smarty) and implement an assign method with stripslashes: <?php class MySmarty extends Smarty { function assign($var, $value) { return parent::assign($var, stripslashes($value)); } } //$tpl = new Smarty(); $tpl = new MySmarty(); ?> -- Ferdinand Beyer <fbeyer@clickhand.de>

« previous php.smarty.general (#5835) next »