Re: [SMARTY-DEV] Re: [SMARTY] Re: [SMARTY-DEV] $smarty.session.object doesn't work in 2.5.0
| From: | Monte Ohrt | Date: | Tue, 15 Apr 2003 16:17:33 +0000 |
| Subject: | Re: [SMARTY-DEV] Re: [SMARTY] Re: [SMARTY-DEV] $smarty.session.object doesn't work in 2.5.0 | ||
| References: | 1 2 3 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-1164@lists.php.net to get a copy of this message | ||
I've always had mixed feelings about accessing outside data with
$smarty. It is handy, but goes against the priciple of assigning content
intended for use within the template. Before we had assign_by_ref(),
assigning was an overhead because an in-memory copy of the data was made
upon each assign, so using the $smarty var for this made sense. Now that
we have assign_by_ref(), I tend to assign everything I plan to use
because there is no performance penalty and it is then treated
unconditionally as assigned data, such as showing up in the debug
console.
Furthermore, when accessing session data directly you are putting
constraints upon where the underlying data comes from. What if this
object would come from another source at some point? You'd have to
adjust all your templates again. If you assign it, then the change is
confined to the application (as it should be!)
So if you were to ask my opinion, I'd do the assign_by_ref() and change
all the template vars. This will work no matter if Smarty supports this
syntax in the future or not.
Monte
On Tue, 2003-04-15 at 10:33, Wom.bat wrote:
> > yep. the problem lies in how $smarty...-refs are compiled now. you
> > have to workaround it in the moment:
> >
> > in php:
> > $smarty->assign_by_ref('session', $_SESSION);
> >
> > and then in $tpl:
> > {$session.user->property}
> hmm... is there any way to inject this $session object into $smarty.* ?
> Or can you tell me the line in Smarty.class.php I need to change, or can you
> fix it in CVS?
> I use $smarty.session in nearly all templates, so I'd have to change it to
> $session in all of them, and change it back after you have fixed it in CVS.
> Or just tell me you'll never do it, I can live with that for sure :)
> Regards,
> David
--
Monte Ohrt <monte@ispi.net>