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

nasty multidimensional 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 -> General
View previous topic :: View next topic  
Author Message
mzanier_XTC
Smarty Regular


Joined: 04 May 2003
Posts: 38

PostPosted: Sat Sep 13, 2003 6:42 pm    Post subject: nasty multidimensional arrays Reply with quote

hi, its me again Wink)

i searched the forum , but didnt found a post for my solution.

how i can went through multidimensional arrays in my templates ?
i got an array like this:

Code:

Array
(
    [0] => Array
        (
            [name] => Modell
            [data] => Array
                (
                    [0] => Array
                        (
                            [id] => 7
                            [text] => Deluxe Ausgabe
                            [price] => 39.6
                            [prefix] => +
                        )

                    [1] => Array
                        (
                            [id] => 6
                            [text] => Premium Ausgabe
                            [price] => 52.8
                            [prefix] => +
                        )

                    [2] => Array
                        (
                            [id] => 8
                            [text] => PS/2 Anschluss
                            [price] => 26.4
                            [prefix] => +
                        )

                    [3] => Array
                        (
                            [id] => 9
                            [text] => USB Anschluss
                            [price] => 13.2
                            [prefix] => +
                        )

                )

        )

    [1] => Array
        (
            [name] => Speicher
            [data] => Array
                (
                    [0] => Array
                        (
                            [id] => 1
                            [text] => 4 MB
                            [price] => 79.2
                            [prefix] => +
                        )

                    [1] => Array
                        (
                            [id] => 2
                            [text] => 8 MB
                            [price] => 66
                            [prefix] => +
                        )

                )

        )

)




how i can went through the array using {foreach} ?


tx for any ideas,
mario
_________________
[quote]
http://www.xt-commerce.com
Back to top
View user's profile Send private message Visit poster's website
mzanier_XTC
Smarty Regular


Joined: 04 May 2003
Posts: 38

PostPosted: Sat Sep 13, 2003 7:56 pm    Post subject: Reply with quote

ah, hat nun geklappt Wink)

Code:

{foreach name=outer item=options_data from=$options}
{$options_data.NAME}
  {foreach key=key_data item=item_data from=$options_data.DATA}
     {foreach key=sub_key item=sub_options from=$item_data}
    {$sub_key}: {$sub_options}
  {/foreach}
  {/foreach}


mfg,
mario
_________________
[quote]
http://www.xt-commerce.com
Back to top
View user's profile Send private message Visit poster's website
mzanier_XTC
Smarty Regular


Joined: 04 May 2003
Posts: 38

PostPosted: Sat Sep 13, 2003 8:16 pm    Post subject: Reply with quote

war doch wohl noch ne ebene zuviel des guten:

Code:

{foreach name=outer item=options_data from=$options}
<b>{$options_data.NAME}</b> <br>
  {foreach key=key_data item=item_data from=$options_data.DATA}
  {$item_data.TEXT}

  {/foreach}

{/foreach}


mfg,
mario
_________________
[quote]
http://www.xt-commerce.com
Back to top
View user's profile Send private message Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sat Sep 13, 2003 9:05 pm    Post subject: Reply with quote

hey mzanier_XTC!

My universal translator stopped working somehwere during this thread. Did you solve your problem?
Back to top
View user's profile Send private message
mzanier_XTC
Smarty Regular


Joined: 04 May 2003
Posts: 38

PostPosted: Sat Sep 13, 2003 9:41 pm    Post subject: Reply with quote

yep, i solved it Wink

Code:

<table width="100" border="0" cellspacing="0" cellpadding="0">
  {foreach name=outer item=options_data from=$options}
  <tr>
    <td class="main"><b>{$options_data.NAME}:</b></td>
    <td>
   <select name="id[{$options_data.ID}]">
  {foreach key=key_data item=item_data from=$options_data.DATA}
  <option value="1">{$item_data.TEXT} ( {$item_data.PREFIX}{$item_data.PRICE} ) </option>
{/foreach}
</select>
</td>
  </tr>
  {/foreach}
</table>


is working for me Wink

boots, i saw some posts in past regarding variables in .conf files, you got any easy solutions there, without mutliple caching a section ?

cause, my shopsystem got like 5.000 cache files for each language/customer group.

regards,
mario
_________________
[quote]
http://www.xt-commerce.com
Back to top
View user's profile Send private message Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sat Sep 13, 2003 9:54 pm    Post subject: Reply with quote

I did write a custom config file handler against 2.5.0 that essentially allows templating within the config file, but it was a test only--I didn't bother to get it to a release stage (it was kinda hacky) or upgrade it to the current CVS (which broke my patch in several ways). It was fun to do at the time but in the end, I couldn't really see the need for it.

Do you mean a variable in a config file that gets parsed at runtime but is not cached? Do you have an example of what you are looking for? Perhaps a config file is not the trick in this case--there may be another approach Smile
Back to top
View user's profile Send private message
mzanier_XTC
Smarty Regular


Joined: 04 May 2003
Posts: 38

PostPosted: Wed Sep 17, 2003 10:07 am    Post subject: Reply with quote

Wink

well it should work like this:

greeting = 'blablabla' $surname $lastname ',blabla'
_________________
[quote]
http://www.xt-commerce.com
Back to top
View user's profile Send private message Visit poster's website
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