Config object and variable scopes
| From: | Hans-Peter Oeri | Date: | Tue, 09 Oct 2001 10:20:56 +0000 |
| Subject: | Config object and variable scopes | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-1632@lists.php.net to get a copy of this message | ||
Hi!
Some more suggestions from my side:
a) public interface for config object
As I got not too much positive feedback for the inclusion of array support
in config files, I have now inherited such a class. It supports both,
wddx/serialized values, a (for me personally) more convenient syntax (I
hated the triple quotes) and caching of config files.
Of course, everyone can have a look at it (I will place it on my web
server), but as it is an incompatible change in the file format, it will
never be included in smarty. I therefore suggest declaring the _conf_obj
attribute as public, so that OTHER implementations of config file objects
may be handled in a defined way (by assigning the object manually).
b) fallback for variable scopes
I never really liked the distinction between config file vars and "other"
vars (assigned by the script or in the template). Indeed, I would
appreciate the possibility to "quickly" overwrite a config file variable.
I therefore changed my compiler class to translate $-variables into:
$output = "(isset(\$this->_tpl_vars['$var_name']$output) ? ".
"\$this->_tpl_vars['$var_name']$output : ".
"\$this->_config[0]['$var_name']$output)";
Like that, I have:
$var = assigned "var", with fallback config "var"
#var# = config "var" only
I could let the compiler class enable/disable the fallback behaviour for
backwards compatibility. However, I officially suggest the inclusion of
such an (optional) fallback behaviour.
As usual, please give me some feedback. I will provide "official" patches,
if liked.
Don't conform!
IkKampfCaspar75