Re[2]: [smarty] how to program this

From: Date: Fri, 29 Mar 2002 10:28:29 +0000
Subject: Re[2]: [smarty] how to program this
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-3396@lists.php.net to get a copy of this message
Hi! :)) i've found this by myself that those index were pain to me. Now it works, but now i make another section and i can't make it work. Here is my new array, i put only one item, because there is problem inside. Array ( [0] => Array ( [0] => Array ( [id_category] => 0011 [name] => item11 [icon] => people.gif [level] => 0 [subs] => Array ( [0] => Array ( [id_category] => 001100 [name] => item1100 [id_parent] => 0011 ) [1] => Array ( [id_category] => 001101 [name] => item1101 [id_parent] => 0011 ) ) ) And here is template <table> <tr> {section name=vrsta loop=$pepe} <td valign="top"> {section name=categorija loop=$pepe[vrsta]} <span><a href="mod/?name=category&id={$pepe[vrsta][categorija].id_category}"><img src="{$themeDir}img/{$pepe[vrsta][categorija].icon}" border="0"></a> <a href="mod/?name=category&id={$pepe[vrsta][categorija].id_category}">{$pepe[vrsta][categorija].name}</a></span><br> <span><small>{section name=sub loop=$pepe[vrsta][categorija].subs} {$smarty.section.sub.index} {$pepe[vrsta][categorija].subs.[sub].name} <-------- problem {* $name *}, {/section} </small>...</span> <br> {/section} </td> {/section} </tr> </table> If you see there is array named $pepe , I mark where the problem is. So loop=$pepe[vrsta][categorija].subs give me right that there is 2 loops (you can see this from array structure) but there is have $pepe[vrsta][categorija].subs which is this array, and it have indexes 0 and 1. Now how can i ouput walue name from this array This does not work {$pepe[vrsta][categorija].subs.[sub].name} if i fill this with ids would be $pepe[0][0][subs][0][name] <--- this i wan't to output. Is there any way to do this. -- lp, Uros mailto:uros.gruber@sir-mag.com Friday, March 29, 2002, 9:58:04 AM, you wrote: DI> I do it the following way: DI> First we need to fix array indexing(use 0,1,2... instead of 4,5,6...) DI> $new_array = array(); DI> foreach(array_keys($my_array) as $i) DI> { DI> $new_array[$i] = array_values($my_array[$i]); DI> } $s->>assign('names',$new_array); DI> and the template(i'm not sure if i'm using the correct variable syntax DI> inside section): DI> <table> DI> <tr> DI> {section name=column loop=$names} DI> <td> DI> {section name=row loop=$names[column]} DI> name: {$names[column][row].name}<br> DI> {/section} DI> </td> DI> {/section} DI> Regards DI> -- DI> Darius Ivanauskas

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