|
Posted by "Cal Henderson" on 06/03/05 21:49
messju mohr wrote:
: On Fri, Jun 03, 2005 at 01:45:44PM +0200, Atte André Jensen wrote:
:: Suppose I have the following in php:
::
:: $array = array('some.test' => 'text', 'more' => 'simple');
:: $smarty->assign('array', $array);
::
:: How do I then address the variable "some.test" in my template?
:
: you can't. stick to [a-zA-Z0-9_] for variablenames.
if you can't avoid it, then you can do this:
{foreach from=$array key='key' item='value'}{if
$key=='some.test'}{$value}{/if}{/foreach}
but that's not so nice. a simple modifier can do it too
{$array|@select:'some.test'}
where the modifier is:
function smarty_select($array, $index){
return $array[$index];
}
$smarty->register_modifier('select', 'smarty_select');
--cal
Navigation:
[Reply to this message]
|