Re: [SMARTY-DEV] Bug in Smarty Compiler concerning constants?
[email protected] (Oliver Jones)
| Newsgroups | php.smarty.dev |
|---|---|
| Organization | Deeper Design Limited |
| Message-ID | <[email protected]> |
On Tue, 2005-03-08 at 19:56 -0800, boots wrote:
> > I see. Well then I will "correct" my code to avoid the bug. Though
> > personally I think it makes the code look very ugly.
>
> It is certainly heavier. sigh.
In all honesty I should probably refactor this template code into some
classes and just have a {admin_menu} function plugin render a data
structure. I've come to the conclusion that whenever possible I should
avoid putting code like stuff into Smarty Templates. It just makes
things much simpler and easier to maintain. But at the moment I just
want things to work. :) Tidy code comes later.
> security is on, but you can alter that by setting the ALLOW_CONSTANTS
> item to true in the $security_settings member. The idea is that if you
> are going to trust constants, you are probably want to trust all
> constants. If there are in fact just a few constants you want to
> expose, you are probably better off simply assigning them to a custom
> associative array template variable (eg: $CONST). By default
> (particularly with security on) arrays are read-only in user templates
> so this amounts to nearly the same thing.
Hmm. I've never experimented with secure mode in smarty. Never had the
need. And indeed assigning constants to some sort of template var in
that case might be a good idea. I'll keep that in mind for the
future.
> aside: PHP5 class constants are not supported at all, AFAIK. Perhaps
> one fine day when someone cooks up the next generation of Smarty it
> will have better integration with PHP constants or maybe it will
> ignore
> them altogether. To paraphrase another PHP list, "Smarty != PHP" (but
> it doesn't fall too far from the tree either)
That is indeed true. Smarty is not PHP. And as I stated above I've
decided it is usually a much smarter plan to use plugin
blocks/functions/modifiers to perform complex logic than it is to try
and create complex Smarty templates.
Regards
--
Oliver Jones » Roving Code Warrior
[email protected] » +64 (21) 41 2238 » www.deeperdesign.com