Re: [SMARTY] htmlentities to all assigned variables

From: Date: Wed, 15 Jan 2003 19:36:26 +0000
Subject: Re: [SMARTY] htmlentities to all assigned variables
References: 1 2 3  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-7204@lists.php.net to get a copy of this message
On Wed, Jan 15, 2003 at 09:06:35PM +0200, Alex wrote: > Hi, > > > On Wed, Jan 15, 2003 at 07:59:50PM +0200, Alex wrote: > >> Hi! > >> I have a following problem: > >> I need to apply htmlentities() function to all assigned variables. > >> I know I can use {$AnyVar|escape} but for this I need to remake a huge > >> template's files. I tried to find any solution with plugins, but I > >> couldn't. Now I have several solution but none of them not looks good. > >> For example I can make Smarty child class and overload assign() > >> function. > >> Anybody have any ideas? > > > all the assigned template-vars are in an associative array in > $smarty->>_tpl_vars > > if you do not assign and modify them inside you template, you can > > modify them all assigned ones before your call to display() or > > fetch(): > > I thought about this way but I have a lot of php files with display() calls. > It's not hard for me to do this, but I am interested to find easier way. > Besides $smarty->_tpl_vars is "private" variable :) you could extend the smarty-class, overload it's display()-function, do the replacement there and call parent::display() . inside that method you maybe even would be allowed to access _tpl_vars, if they are only "private" but not "protected". :) honestly: i know it is bad style to access _tpl_vars directly, but it makes such a hell of things so damn easy. blame on lazy me :) regards messju > Alex.

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