Re: [SMARTY] template from var

From: Date: Mon, 30 Aug 2004 15:31:48 +0000
Subject: Re: [SMARTY] template from var
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11740@lists.php.net to get a copy of this message
--- Paul <pardel@gmail.com> wrote: > Still, I would like to know it ;) > Cheers, > Paul I agree with bok, don't use this, but here is a dirty one -- it assumes the variable is a global but uses Smarty's standard way of redirecting input, namely a resource: function smarty_resource_var_source($tpl_name, &$tpl_source, &$smarty) { global $$tpl_name; $tpl_source = $$tpl_name; return true; } function smarty_resource_var_timestamp($tpl_name, &$tpl_timestamp, &$smarty) { $tpl_timestamp = ''; return true; } function smarty_resource_var_secure($tpl_name, &$smarty) { return true; } function smarty_resource_var_trusted($tpl_name, &$smarty) { return; } eg: $bar = 'eek!'; $foo = '{$bar}'; $smarty->assign('bar', $bar); $smarty->display('var:foo'); NOTE: examine your compiled/cache dirs after this one runs -- you may not like it. xo boots > On Mon, 30 Aug 2004 22:50:44 +1000, Robert Amos <shiznatz@gmail.com> > wrote: > > Theres an ugly hack you can use from within a php file, but you're > > better off avoiding it as best you can. > > > > -bok > > > > On Mon, 30 Aug 2004 13:59:05 +0200, Stefan <e.tuli@gmx.de> wrote: > > > Paul wrote: > > > > > > >Hi all, > > > >Is there any way to use the content of a variable as a template? > > > >Thank you! > > > >Paul > > > > > > > inside a template use {eval}. Inside a php file, assign it to an > > > existing template. Afaik there's no other possibilty of > evaluation > > > template code withing php code without loading it directly from a > file.

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