looping foreach
| From: | Rainer Bendig aka Ny | Date: | Wed, 17 Nov 2004 14:15:02 +0000 |
| Subject: | looping foreach | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-11971@lists.php.net to get a copy of this message | ||
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
i've got the fallowing issue:
Array (4)
0 => Array (6)
a => empty
b => Ausgangsstelle
c => m
d => 0
e => 1
f => empty
1 => Array (6)
a => index
b => Start
c => s
d => 1
e => 2
f => empty
2 => Array (6)
a => s2
b => sub2
c => s
d => 3
e => 4
f => empty
3 => Array (6)
a => empty
b => Cat2
c => m
d => 0
e => 3
f => empty
$array.a is a link its converted via template to {$array.a}.html
$array.b is simple text
$array.c is the role of the entry m for master and s for slave
$array.d is the value of $item.e if $item.c is "s" and stands for the main category
$array.e is the id of the mysql entry
$array.f is unused until now, and will become "show on sitemap" or something else)
the array is sorted via mysql statement - will smarty keep the sorting or should i sort it via
template (if, how?)
the array should be used to build an menu aka this sample:
ArrayID 0 ($item.c=m)
|- ArrayID 1 ($item.c=s)
ArrayID 2 ($item.c=m)
|- ArrayID 3 ($item.c=s)
I tried to build it via the fallowing sample of the wiki ($navm is my array name)
{foreach name=outer item=navm from=$navm}
{foreach name=inner key=key item=item from=$navm}
<div id="l4navpoint">{$key.b}}</div>
{/foreach}
{foreach key=key item=item from=$navm }
<div id="l4subnav">
<span class="bold">»</span> {$item.b}
</div>
{/foreach}
{/foreach}
I also tried to work with two arrays (seprated master and slave) but didn't get it to work,
because i dont know how to filter the array in the template, and i also think its to slow
thx in advice
rainer
(This is my first post to the list, if i should turn off gpgsigning, please tell)
- --
- ---------------------------------------------------------------------
Rainer 'Ny' Bendig | http://UnresolvedIssue.org |
GPG-Key: 0xCC7EA575
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
iD8DBQFBm1zmtpAZoWtAN98RAjvqAJ9cIN9L3HMOgXgUdKs32hBIiLJz2gCfYsWs
hXQjRvrRKNBWcHhDojgYTK0=
=Khha
-----END PGP SIGNATURE-----