Re: [SMARTY] Smarty, associative arrays and underscores not playing nicely

From: Date: Sat, 11 Oct 2003 14:50:40 +0000
Subject: Re: [SMARTY] Smarty, associative arrays and underscores not playing nicely
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-10336@lists.php.net to get a copy of this message
On Sat, Oct 11, 2003 at 11:31:38AM +0100, Duncan Hill wrote: > I've been having great 'fun' with Smarty, associative arrays and briefly, > sections. > > I have a subroutine that returns an associative array that's keyed by strings, > not numeric indices. The general structure of the array is: > $data = array('key' => array('reccount' => '2', > 'value_1' => 'Foo', 'value_2' > => 'Bar' )); > $sm->assign('data', $data); > > My smarty code looks like: > {$data.key.reccount} > {$data.key.value_1} > > The first statement prints '2'. Perfect. > The second statement prints.. nothing. > > Are underscores taboo or something in Smarty? AFAIK no. the problem must be somewhere else in your code. both 2.5.0 and 2.6.0-RC2 translate "{$data.key.value_1}" to "<?php echo $this->_tpl_vars['data']['key']['value_1']; ?>" which looks fully correct to me. greetings messju > (I tried the following with no success as well, does section require numeric > indices? > > {section name=row loop="$data"} > {$data[row].value_1} > {/section} > > I expected that to get a value of 'key' for row, and print out 'Foo'. But > it > didn't.) > > I've tried Smarty 2.5, and 2.6RC2 now. > > -- > Smarty General Mailing List (http://smarty.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.smarty.general (#10336) next »