Re: [SMARTY] {assign}ing global vars?

From: Date: Wed, 10 Dec 2003 01:20:47 +0000
Subject: Re: [SMARTY] {assign}ing global vars?
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10651@lists.php.net to get a copy of this message
--- Luna Kid <listreader@neuropolis.org> wrote: > As I see, included templates can only assign variables > locally (file-scoped or something like that). > > I guess conf variables are global, but they are treated > differently from normal template vars (at least the > syntax differs.) > > 1. How do conf. vars actually differ from templ. vars? > (And if they really do, why (the hell ;) )?) They are compiled into their own source and simply included into the template instead of being produced at runtime (that's simplified a little, but essentially correct). AFAIK, you can not modify config vars from anywhere except the config file itself. Config vars are presently somewhat limited in what they can contain whereas template vars can contain any valid php value including arbitrarily nested arrays, associative arrays and even objects. Finally, it is possible to assign template vars using references if desired. > 2. Can I achieve global scoping of normal template vars > similar to conf vars? (I'd like to include common files > that both output things and {assign} variables for the > including (parent) file. The most likely need for something like this is to package application functionality into your template--this is typically considered verboten. The forum has more on this: Discussion: http://www.phpinsider.com/smarty-forum/viewtopic.php?t=936 Patch (old--may no longer work): http://www.phpinsider.com/smarty-forum/viewtopic.php?t=934 Hope that helps. __________________________________ Do you Yahoo!? New Yahoo! Photos - easier uploading and sharing. http://photos.yahoo.com/

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