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

SECTION and arrays ?

 
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 -> Tips and Tricks
View previous topic :: View next topic  
Author Message
gordonisnz
Smarty Regular


Joined: 05 Sep 2009
Posts: 70

PostPosted: Sun Mar 04, 2012 11:11 am    Post subject: SECTION and arrays ? Reply with quote

Hello.

I'm used to doing foreach routines in smarty, but now discovered the SECTION function, to display 2-column tables Smile

Its easy enough.

However, I have an array

Data1
-Name=Bob
-Surname=Jones
-Region=USA
Data2
-Name=Jill
-Surname=Jacks
-Region=USA
Data3
-Name=John
-Surname=Jacks
-Region=Britain

Are there any examples / tutorials to do an IF command - Or using SECTION, to only display information if "Region" is USA ??

and then, to display $array[$loop][Name] - Or something, so i can display or not to display a variable ?

in a FOREACH loop, you have 'key' & 'item' which you can use to reference data, but i can't see in the examples I've found, how you use 'key' or 'item' equivalents in the section command.

Thank you
Back to top
View user's profile Send private message
gordonisnz
Smarty Regular


Joined: 05 Sep 2009
Posts: 70

PostPosted: Sun Mar 04, 2012 12:07 pm    Post subject: Reply with quote

I read online that the SECTION function is a bit limited, and we should use foreach.

I found a useful smarty script that worked

http://smarty.incutio.com/?page=SmartyColumnsTutorial
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 -> Tips and Tricks 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