|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
zeroK Smarty n00b
Joined: 30 Jun 2003 Posts: 3
|
Posted: Mon Jun 30, 2003 5:52 pm Post subject: Nested Sections (Loops, ...whatever is needed) ? |
|
|
Hi there I'm new to Smarty so please forgive me if this is a stupid question
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 |
|
Enquest Smarty Regular
Joined: 14 May 2003 Posts: 79
|
Posted: Mon Jun 30, 2003 9:18 pm Post subject: |
|
|
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 |
|
zeroK Smarty n00b
Joined: 30 Jun 2003 Posts: 3
|
Posted: Mon Jun 30, 2003 9:38 pm Post subject: |
|
|
The problem is, that the database source for my 2nd section has to be fetched with the cat_id provided by the first section. |
|
Back to top |
|
zeroK Smarty n00b
Joined: 30 Jun 2003 Posts: 3
|
Posted: Mon Jun 30, 2003 9:49 pm Post subject: |
|
|
Tnx. I solved my problem by restructuring my data. |
|
Back to top |
|
|
|
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
|