Smarty and constants
| From: | Erik Schmitt | Date: | Wed, 13 Jul 2005 12:34:16 +0000 |
| Subject: | Smarty and constants | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-12799@lists.php.net to get a copy of this message | ||
Hello,
recently I asked how to access constants in a dynamic way.
The solution is to use
{$smarty.config.$bla} instead of {#$bla#}.
But in my case $bla is the result of calling an
object method. Hence I have to write:
{assign var="bla" value=$myObject->myMethod()}
{$smarty.config.$bla}
Somethink like {$smarty.config.
$myObject->myMethod()}
does not work.
On the other hand, smarty will stop with a syntax error
if it finds a leading $ like in {#$bla#}. So what about
simply allowing smarty to evaluate the "content" if it starts
with a $?
(In my case, the methods are returning IDs for strings in
a language files, with some of the IDs stored in a DB).
What do you think?
- Erik