By: xotix
Date: 2010-12-06
Time: 11:16
|
Assoziative Array in templateHi, so i have an array which looks like that:
Array ( [0] => Array ( [goods] => Array ( [0] => Array ( [Food_ID] => 4 [Titel_DE] => Rotweinbirne mit hausgemachtem Rotweineis [Titel_EN] => [Titel_IT] => Poire au vin rouge glace vin rouge fait maison [Describtion_DE] => [Describtion_EN] => [Describtion_IT] => [PriceMain] => 25 [PriceSec] => 0 [PriceMainDesc] => [PriceSecDesc] => ) ) [catDetails] => Array ( [Categorie_ID] => 19 [Titel_DE] => eee [Titel_EN] => [Titel_IT] => [Describtion_DE] => [Describtion_EN] => [Describtion_IT] => ) ) ) can i somehow access the entries of the array in the tempalte with theire indexes? like [a;block=begin] [a.goods.0.Titel_DE] [a;block=end] ? that would be nice. |
|
By: Skrol29
Date: 2010-12-06
Time: 18:12
|
Re: Assoziative Array in templateHi,
Yes, your snippet seems correct. Doesn't it work? |
|
By: xotix
Date: 2010-12-07
Time: 10:05
|
Re: Assoziative Array in templateNo, it didnt. But i will try it again and post all my code.
|
|
By: xotix
Date: 2010-12-07
Time: 12:26
|
Re: Assoziative Array in templateso, it worked. Thanks :)
So 1 question: if i have a loop like this [c.goods;block=begin] [c.goods.0.Titel_DE] [c.goods;block=end] is it correct to ent the block with c.goods, or could i just use c? it works liek that. also, i want to autocount the 0. i thougth i can do that with the $ symbol, but then i get the warning: in field [c.goods.$.Titel_DE...]: item '$' is not an existing key in the array. Thanks |
|
By: Skrol29
Date: 2010-12-07
Time: 14:58
|
Re: Assoziative Array in template> is it correct to ent the block with c.goods, or could i just use c?
If you use block=begin/block=end, the correct syntax is with the name of the block alone. This is because such fields are markers for the block bounds. If you use block=tag, then you can either add a sub-name of not. With a sub-name they have the double function: define block bounds, plus display a field's value. Without a sub-name, they are only used to define the block bounds. > i thougth i can do that with the $ symbol Yes but is it relative to the current record only, not the number of items in a sub-array. The correct syntax is: [c.$]. |
|
By: xotix
Date: 2010-12-07
Time: 15:37
|
Re: Assoziative Array in templatei got a array like:
i got a numeric array, each entry got an array with 2 associative entries ( goods, detail) and goods also got an numeric array. so i want of every array the goods part to loop. my array looks like: http://pastebin.com/5M0aeTXR i want to loop over the first level, so through each categorie. then i just need the goods part. what do you mean with, it is relative to the current record only? why should he care if it is a sub array or not? he doesnt like now it. I pass an array, if that array is now the 3rd or 1th level shouldnt matter. i just wanted to use the $ on the last numeric level. |
|
By: xotix
Date: 2010-12-08
Time: 07:38
|
Re: Assoziative Array in template[c;block=begin;sub1]
[c_sub1;block=begin; when [c_sub1.$] == goods] [c_sub1.0.Titel_DE] [c_sub1;block=end] [c;block=end] thas what i got now. so $ represents the key, in this case it c_sub1.$ would be goods or catDetails. so it does the block just if it is goods. thats very nice! now, i want to loop througth the goods array. it is a numeric array. i tried: doing a sub2, didnt work. and yo'veu never done it right? can i somehow begin a new loop and like pass the cat_sub1.$? like: [c;block=begin;sub1] [c_sub1;block=begin; when [c_sub1.$] == goods] [c_sub1.$;block=begin] [Titel_DE] [c_sub1.$;block=end] [c_sub1;block=end] [c;block=end] that doesnt work either, it outputs me goods [title_de] goods etc. hmm, i somehow need to loop the goods array. or i need something like i++; so the first loop it is 0 then say add one for each loop. but i didnt find anything in the manual. if i could make a coutner into my loop, everything would be perfect. ^^ |
|
By: Skrol29
Date: 2010-12-08
Time: 11:22
|
Re: Assoziative Array in templateHi Xotix,
I think, here is what you need for the result you're expecting:
> what do you mean with, it is relative to the current record only? $ and # are TBS virtual columns that represents respectively the key and the row number of the current record merged by TBS. Thus, those virtual columns do not exist under sub-values, even if the sub-value is an array. [myblock.$] is ok, but [myblock.column.$] cannot work. |
|
By: xotix
Date: 2010-12-08
Time: 13:36
|
Re: Assoziative Array in templateOh yeah, thanks a lot! thats perfect. :) Thanks and have a nice day.
|