Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Nested Sections (Loops, ...whatever is needed) ?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
zeroK
Smarty n00b


Joined: 30 Jun 2003
Posts: 3

PostPosted: Mon Jun 30, 2003 5:52 pm    Post subject: Nested Sections (Loops, ...whatever is needed) ? Reply with quote

Hi there Smile I'm new to Smarty so please forgive me if this is a stupid question Smile

Is something like that possible?
Code:
<table>
   {section name=cats loop=$categories}
   <tr>
      <td class="category_icon"></td>
      <td class="category_name">
         <a href="index.php?cat_id={$categories[cats].cat_id}">{$categories[cats].cat_name}</a>
      </td>
   </tr>   
   {section name=forums_{$categories[categories].cat_id} loop=$forums_{$categories[cats].cat_id}}
   <tr>
      <td colspan="3"> » {$forums_{$categories[cats].cat_id}[forums_{$categories[cats].cat_id}].forum_name}</td>
   </tr>
   {/section}
   {/section}
</table>


The main problem is, that I want to select the source for the nested-loop-data with a variable provided by the outer loop.
Back to top
View user's profile Send private message
Enquest
Smarty Regular


Joined: 14 May 2003
Posts: 79

PostPosted: Mon Jun 30, 2003 9:18 pm    Post subject: Reply with quote

I think your on the right track

it easy to
{section 1}
$var1
{section 2}
$var1 (to get that variable from the section 1 loop. Note as long as you are in section 2 the variable of section 1 won't change!)
{/section}
{/section}

In your second loop I think you should change your name of the section. To something more readebel. In the second loop you always can acces the current first loop. So ther is no need to make such a complicated name. Alas that's what I think. I hope I'm write as I'm not an expert!. But if you have a problem look at the name.
Only trying to help!
_________________
-----------------------
Learning my self by trying to help others
Back to top
View user's profile Send private message
zeroK
Smarty n00b


Joined: 30 Jun 2003
Posts: 3

PostPosted: Mon Jun 30, 2003 9:38 pm    Post subject: Reply with quote

The problem is, that the database source for my 2nd section has to be fetched with the cat_id provided by the first section. Wink
Back to top
View user's profile Send private message
zeroK
Smarty n00b


Joined: 30 Jun 2003
Posts: 3

PostPosted: Mon Jun 30, 2003 9:49 pm    Post subject: Reply with quote

Tnx. I solved my problem by restructuring my data. Smile
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP