Re: [SMARTY] defining arrays in config files

From: Date: Mon, 23 Feb 2004 19:55:46 +0000
Subject: Re: [SMARTY] defining arrays in config files
References: 1 2 3 4 5 6  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-11007@lists.php.net to get a copy of this message
I think that it's exactly what we gonna do. This syntax highlighted as well to me to be used in config files following the logic of the template syntax as described in the doc. Moreover, we need to support key assignation : [section] foo.bar[0] = testme foo.bar[1] = testme2 bar[0].foo = blabla as well as key names coming from php constants or assigned php variables : [section] foo.bar[$ERRNO1] = testme foo.bar[$smarty.const.ERRNO2] = testme2 bar.$key_string1 = blabla bar.$ERRNO3 in order to support nicely error msg displaying with error codes (but also simple messages display). Then we can access them in templates this way : {#foo.bar[$errno]#} // we have a $errno = ERRNO1; in php for example and then $errno is assigned to smarty {#bar.$key_string1#} Tarik "Monte Ohrt" <monte@ispi.net> a écrit dans le message de news:1077565107.8380.56.camel@cyrus.ispi.prv... > Associative arrays in config files are something that has come up in the > past, it would be a nice addition. Here are some things to consider: > > Smarty's syntax for displaying an associative array is of the form: > > {$foo.bar.blah} > > So it makes sense to follow the same convention in the config file: > > [section] > foo.bar.blah = testme > foo.bar.blah2 = testme2 > > > Now to see if this syntax breaks anything. Periods are not allowed in > config variable names, so that should be easy to implement. Hidden > variables start with a period, so that shouldn't be a problem either: > > .foo.bar.blah > > This is how they would be displayed in the template: > > {#foo.bar.blah#} > {$smarty.config.foo.bar.blah} > > That syntax is invalid, so support for it would need to be added to the > parser. > > Smarty compiles config files into php files so that might need > attention, but will most likely work fine. > > Monte

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