|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
tdm Smarty Rookie
Joined: 01 May 2003 Posts: 18
|
Posted: Mon Aug 18, 2003 5:38 pm Post subject: Dynamic config variables? (like {#color{$colorname}#}?? |
|
|
I have some colors set in my config file, named like 'color[groupname]' where [groupname] could be 'home', 'esta', 'scout', 'explo'.
{note: This is about a news page}
Every news message contains one field which tells me for which group the message is. So I did this in my template:
Code: | {section name='newslist' loop=$results}
<tr bgcolor="{#color{$result[newslist].sidname}#}">
<td class="adminNewsOverviewTitleRowCell">{html_link page="nieuws.php" nid=$results[newslist].nid title=$results[newslist].title text=$results[newslist].title|truncate:30}</a></td>
<td class="adminNewsOverviewSpeltakRowCell">{$results[newslist].sidname}</td>
<td class="adminNewsOverviewDateRowCell">{$results[newslist].postdate|date_format:"%a %d-%m-%Y %H:%M"|capitalize}</td>
<td class="adminNewsOverviewFunctionsRowCell">[ <a href="#">{#adminNewsOverview_functionEdit#}</a> | <a href="#">{#adminNewsOverview_functionDelete#}</a> ]</td>
</tr>
{/section} |
To make clear about which part I'm talking about:
Code: | {section name='newslist' loop=$results}
<tr bgcolor="{#color{$result[newslist].sidname}#}"> |
This gives me an error like:
Code: | Fatal error: Smarty: [in admin/admin_nieuws_overview.tpl.html line 46]: syntax error: unrecognized tag: #color{$result[newslist].sidname (Smarty_Compiler.class.php, line 410) in /home/httpd/htdocs/ascanenv2.nl/includes/Smarty/Smarty_Compiler.class.php on line 2040 |
How can I do this right, so it gives the output of the 'color[groupname]' constant like I have set it in my config file?
Thanks |
|
Back to top |
|
CirTap Smarty Pro
Joined: 04 Jun 2003 Posts: 106
|
Posted: Mon Aug 18, 2003 6:12 pm Post subject: |
|
|
Re,
I think you have to use backticks for this, but I never tried to create variable variable-names with Smarty
Code: | <tr bgcolor="{#color`$result[newslist].sidname`#}"> |
http://smarty.php.net/manual/en/language.syntax.quotes.php
If this does not work, load the Config-File in PHP and add the color as a new key to the $result array. This is probably less trouble and you can stoll use the config files to change the colors.
See this thread about reading config files in PHP.
Have fun,
CirTap |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|