Re: [SMARTY] defining arrays in config files
| From: | Monte Ohrt | Date: | Mon, 23 Feb 2004 19:38:27 +0000 |
| Subject: | Re: [SMARTY] defining arrays in config files | ||
| References: | 1 2 3 4 5 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-11005@lists.php.net to get a copy of this message | ||
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
On Mon, 2004-02-23 at 12:12, pete M wrote:
> Think were looking at the
>
> function _parse_config_block($config_block)
>
> and
> function _set_config_var(&$container, $var_name, $var_value, $booleanize)
>
> in Config_File.class.php
>
> Pete
>
>
> Tarik Ansari wrote:
>
> > Pete M we completely agree on that (and as I said on php.smarty.dev), then
> > let's improve ourselves smarty code and then we submit it to the CVS, I am
> > very ready to do this as I will not do anything more on my current project
> > as long as smarty doesn't read arrays in config files. I will take a look to
> > smarty code in the following days and post my code propositions on
> > php.smarty.dev to discuss the efficacity of it and improve it from immediate
> > comments before CVS.
> >
> > Tarik
> >
> > "Pete M" <pmorgan@ukds.net> a écrit dans le message de
> > news:20040223124438.18776.qmail@pb1.pair.com...
> >
> >>This just makes it more confusing for the end user...
> >>
> >>At the moment I have a multilingual staff members who does some of the
> >>translation in the condig file and some in a php file.
> >>
> >>Respecting arrays in the config file (in load sections) would solve this
> >>problem and thereby completely seperate the php logic from the templates
> >>IMHO.
> >>
> >>pete
> >>
> >>
> >>Marcus Bointon wrote:
> >>
> >>>on 21/2/04 13:03, Tarik ANSARI at ansari@efrei.fr wrote:
> >>>
> >>>
> >>>
> >>>>If I am using smarty, it's because I want to be able to make my project
> >>>>translated only by templates files, there should be zero text strings in
> >
> > any
> >
> >>>>php script of my project when completed. We shouldn't have to define
> >
> > those
> >
> >>>>kind of strings in php while config files are made for this. There is no
> >>>>reason to Smarty for not supporting it...
> >>>
> >>>
> >>>All I'm saying is that there's effectively no difference in concept or
> >>>function between a parsed Smarty template and an included PHP file other
> >>>than the syntax you used to fill it. I'm not disputing that it might be
> >
> > a
> >
> >>>nice feature to have so that you can use Smarty syntax throughout, but
> >
> > it's
> >
> >>>not one that breaks code/content separation in any way. Just because a
> >
> > file
> >
> >>>happens to have a .php suffix doesn't mean it can't be legitimately be
> >>>regarded as being on the "content side" of things, though I suppose it
> >
> > might
> >
> >>>confuse some. Code/content separation is about concept rather than
> >
> > syntax.
> >
> >>>Marcus