|
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 |
rado Smarty n00b
Joined: 14 Jul 2003 Posts: 1
|
Posted: Mon Jul 14, 2003 5:31 pm Post subject: sections with 2-dimensional arrays |
|
|
Hi, I've read a lot threads about Smarty sections and arrays but couldn't find my problem.
I have 2 nested sections:
{section name="sm_row" loop=$rownum} and {section name="sm_col" loop=$rowanz[$smarty.section.sm_row.index]}
my array is of the style: sitemap[x][y].item
I try to access this array in smarty like this:
{$sitemap[$smarty.section.sm_row.index][$smarty.section.sm_col.index].sub2}
Don't get any results. Not even an error. Just nothing.
I have other templates with single sections and single arrays same style, they work pretty well.
Thx for any hints, Rado |
|
Back to top |
|
Enquest Smarty Regular
Joined: 14 May 2003 Posts: 79
|
Posted: Mon Jul 14, 2003 6:06 pm Post subject: |
|
|
Ok I could be wrong but I''m sure Boots or somebody will correct me..
I think the problem must be the second section. That would be the place wher I would be looking. Maybe how the loops work
Could you eleborate how this array look like. Maybe print_r _________________ -----------------------
Learning my self by trying to help others |
|
Back to top |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Mon Jul 14, 2003 9:48 pm Post subject: |
|
|
Me correct someone?
Actually, I'd just try to side-step this issue entirely by switching to foreach loops or using intermediate assignments. Sections can be a pain, especially when nested. Things like [$smarty.section.sm_row.index] make me queasy.
ASIDE:
Sections are sometimes a little more managable if you use the (I believe depracated, oh horrors) little-known % syntax (eg. [%sm_row.index%]) but unfortunately, that is not really a *recommended* feature. But I'm no snitch and as I'm not privvy to the reasons it has been deprecated, I can't see why it shouldn't at least be mentioned since it is still supported--for now.
I didn't test the issue, so I can't give a more definitive answer--sorry!
HTH |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Mon Jul 14, 2003 10:46 pm Post subject: |
|
|
to me (knowing php's foreach) foreach is much easier to grasp than section, but anyway:
{$sitemap[$smarty.section.sm_row.index][$smarty.section.sm_col.index].sub2}
is not working, for reasons unknown to me, but it boils down to
{$sitemap[sm_row][sm_col].sub2} anyway.
i didn't run it, but it looks much better regarding the php-code that smarty generates for the latter. |
|
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
|