Smarty PHP section looping problem

This is a discussion on Smarty PHP section looping problem within the PHP General forums, part of the PHP Programming Forums category; Hi, I'm implementing smarty and I am trying to loop through some arrays. I have this piece of code ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-15-2003
Mark Lancaster
 
Posts: n/a
Default Smarty PHP section looping problem

Hi,

I'm implementing smarty and I am trying to loop through some arrays.

I have this piece of code in a template:

{foreach key=outer_number item=out from=$outer}
<b> {$out.id}</b> <br>
{section name=inner_number loop=$inner[$out.id]}
{$inner[$out.id][inner_number].name} <br>
{/section}
{/foreach}


which once the arrays are filled produces:

7618
7617
7616
7615

As you can see the code is looping through the outer array, displaying
the id but never gets into the inner array using $out.id.

For de-bugging purposes I have hard-coded $out.id with 7618 (one of
the displayed $out.id's) the code now looks like:

{foreach key=outer_number item=out from=$outer}
<b> {$out.id}</b> <br>
{section name=inner_number loop=$inner[7618]}
{$inner[7618][inner_number].name} <br>
{/section}
{/foreach}

which produces:

7618
Goodwin
Montgomerie
Cottey
Adams
Ambrose
Martin-Jenkins
Prior
Davis
Kirtley
Lewry
7617
Goodwin
Montgomerie
Cottey
Adams
Ambrose
Martin-Jenkins
etc
etc

The code is now looping through the outer array and the inner array.

Can anyone suggest how I can get the code to properly use $out.id
inside the inner loop?

Thanks
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:57 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0