Re: [SMARTY] Disabling Output filters

From: Date: Sat, 08 Feb 2003 12:37:56 +0000
Subject: Re: [SMARTY] Disabling Output filters
References: 1 2 3  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-7597@lists.php.net to get a copy of this message
On Sat, Feb 08, 2003 at 11:44:48AM +0100, M Mohr wrote: > On Fri, Feb 07, 2003 at 11:09:50PM +0100, M Mohr wrote: > > On Fri, Feb 07, 2003 at 06:50:56PM +0100, Ernesto Baschny wrote: > > > Hi! > > > > > > I have some nested templates and would like only to have the > > > outputfilter to apply to the final resulting output. > > > > > > To do that I would like to have a way to (temporarily) switch off > > > outputfilters, something like $smarty->disable_outputfilters() and > > > a corresponding $smarty->enable_outputfilters(). That way I don't > > > have to unregister before and register them again afterwards, a > > > not so trivial task, as I have no (documented) way of knowing which > > > filters are currently loaded. > > > > > > Or is there some way of doing that already? > > > > it is far from perfect, but i would fetch() the template without any > > output-filters enabled and apply the filter to the result of fetch > > afterwards. > > on second thougt: my suggestion won't work with caching unfortunately. > another approach could be to extend smarty and override the > fetch()-function: > > [not tested] > class MySmarty extends Smarty { > var $include_depth = 0; > > function fetch($_smarty_tpl_file, $_smarty_cache_id = null, $_smarty_compile_id = null, > $_smarty_display = false) { > > $this->include_depth++; > $ret = fetch($_smarty_tpl_file, $_smarty_cache_id, $_smarty_compile_id, $_smarty_display) upsi! this ^^^ has to be parent::fetch(...) , of course. > $this->include_depth--; > return $ret; > } > } > > then you can ask $smarty->include_depth from inside your outputfilters. > if it is 1 the filter is applied to the outermost template. if it is greater than > one, it is called from a nested one. > > > HTH > > messju > > > > > Thanks! :) > > > > > > Ernesto > > > > > > > > > > > > -- > > > Smarty General Mailing List (http://smarty.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- Giga: Teletubbies für Skriptkinder. Joerg-Olaf Schaefers

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