|
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 |
foxmask Smarty Rookie
Joined: 04 Feb 2004 Posts: 23 Location: Paris / France
|
Posted: Sat Jun 10, 2006 3:12 pm Post subject: [fixed with modifier.lookup] index name with space |
|
|
hi,
i have an array where some of the index name contain space like :
$lang_common['Show new posts']
$lang_common['Show unanswered posts']
now i'd like to display them in my template, so i did :
php code :
Code: |
$tpl->assign('lang_common',$lang_common);
|
template code
Code: |
{$lang_common.Show%20unanswered%20posts}
{$lang_common.Show%20new%20posts}
|
but nothing happens.
i've also tried
{$lang_common['Show unanswered posts']}
or
{$lang_common["Show unanswered posts"]}
but i've the error :
Fatal error: Smarty error: [in default.tpl line 50]: syntax error: unrecognized tag: $lang_common['Show unanswered posts']
any suggestion ? _________________ Smarty Fan Since 2.5
Last edited by foxmask on Sat Jun 10, 2006 8:57 pm; edited 1 time in total |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sat Jun 10, 2006 8:08 pm Post subject: |
|
|
Hi.
Smarty doesn't play nicely with spaces in key names (nor with periods), If possible, convert them to something like "Show_new_posts", etc. Otherwise you need to use a temporary var:
Code: | {assign var=foo value="Show new posts"}
{$lang_common.$foo} or {$lang_common[$foo]} |
Another idea is to use something like the lookup modifier I posted in this thread: http://www.phpinsider.com/smarty-forum/viewtopic.php?t=3806
Using that, you are able to do things like:
Code: | {"Show new posts"|lookup:$lang_common} |
HTH |
|
Back to top |
|
foxmask Smarty Rookie
Joined: 04 Feb 2004 Posts: 23 Location: Paris / France
|
Posted: Sat Jun 10, 2006 8:22 pm Post subject: |
|
|
A big Thanks to You !
Its working perfectly ! _________________ Smarty Fan Since 2.5 |
|
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
|