Demo

Probiere ClanSphere aus und teste daran herum. Demo


Antworten: 11
Seite [1]
Horr


Wannabe poster




Beiträge: 25
# Thema - 28.07.2012 um 18:51 Uhr
Im looking for some way to do this:

test.php

$arrayTest['SOMETHING']['SOMETHINGELSE'][0] = 'test1';
$arrayTest['SOMETHING']['SOMETHINGELSE'][1] = 'test2';
$arrayTest['SOMETHING']['SOMETHINGELSE'][2] = 'test3';
$arrayTest['SOMETHING']['SOMETHINGELSE'][3] = 'test4';
$arrayTest['SOMETHING']['SOMETHINGELSE'][4] = 'test5';

$data['somethingArray'] = $arrayTest;

test.tpl

{loop:somethingArray}

How can i loop the SOMETHINGELSE array here?

{stop:somethingArray}
Inaktiv
palle ClanSphere Team

Supporter
Supporter




Beiträge: 3073
# Antwort: 1 - 28.07.2012 um 19:18 Uhr
 
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
1. / 2. / ... 
<?php

$cs_lang 
cs_translate('modname');

$test = array('test1','test2','test3','test4','test5');

//While-Schleife: {loop:something}{something:somethingelse}<br />{stop:something}

$i 0;
while(
$i count($test))
   {
   
$data['something'][$i]['somethingelse'] = $test[$i];
   
$i++;
   }


//For-Schleife: {loop:something}{something:somethingelse}<br />{stop:something}
for($i=0$i count($test); $i++)
   {
   
$data['something'][$i]['somethingelse'] = $test[$i];
   }

//No loop {something:somethingelse1}<br />{something:somethingelse2}<br />{something:somethingelse3} etc...
   
$data['something']['somethingelse1'] = $test['0'];
   
$data['something']['somethingelse2'] = $test['1'];
   
$data['something']['somethingelse3'] = $test['2'];
   
$data['something']['somethingelse4'] = $test['3'];
   
$data['something']['somethingelse5'] = $test['4'];   

echo 
cs_subtemplate(__FILE__,$data,'modname','modfile');


------------------
I like the part where it says 'nyan'



Zuletzt editiert von palle ClanSphere Team am 28.07.2012 um 19:25 Uhr (2x Editiert)
Inaktiv
|
Horr
Thread-Ersteller


Wannabe poster




Beiträge: 25
# Antwort: 2 - 28.07.2012 um 20:04 Uhr
Thanks for the answer, but actually, its a dynamic array. I dont know what is the key value.

There's some way to foreach in .tpl?


Inaktiv
|
Jam2 ClanSphere Team


Highlander





Beiträge: 3291
# Antwort: 3 - 28.07.2012 um 20:18 Uhr
I think you search something like this, right?

 
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
1. / 2. / ... 
 
    $count 
count($array);
    for(
$i=0$i $count$i++)
    {
        
$data['something'][$i]['var'] = $test[$i];
        for(
$i2=0$i2 $count$i2++)
        {
            
$data['something'][$i]['somethingelse'][$i2]['var'] = $test[$i2];
        }
    }

/*
{loop:something}
    {something:var}
    {loop:somethingelse}
        {somethingelse:var}
    {stop:somethingelse}
{stop:something}
*/ 


------------------
Gruß/ Best regards
Jam2

Nützliche Forumbeiträge/Codepastes: (Useful comments in our board / codepastes)
Template Switch for index.php
Board Navlist last posts

Edi: könnte man denn auch hier eine erweiterung einfügen?
Jam2: das web ist wie toyota.....
Edi: hö ?
Jam2: nichts ist unmöglich!


Inaktiv
|
Horr
Thread-Ersteller


Wannabe poster




Beiträge: 25
# Antwort: 4 - 28.07.2012 um 20:31 Uhr
My key can be anything.. and i want to loop it on .tpl without know what is it.


Zuletzt editiert von Horr am 28.07.2012 um 20:31 Uhr (1x Editiert)
Inaktiv
|
Jam2 ClanSphere Team


Highlander





Beiträge: 3291
# Antwort: 5 - 28.07.2012 um 21:34 Uhr
Ok, I think you have to put a sample array here :O. I think the while() loop from Palle is that thing what you want ...



------------------
Gruß/ Best regards
Jam2

Nützliche Forumbeiträge/Codepastes: (Useful comments in our board / codepastes)
Template Switch for index.php
Board Navlist last posts

Edi: könnte man denn auch hier eine erweiterung einfügen?
Jam2: das web ist wie toyota.....
Edi: hö ?
Jam2: nichts ist unmöglich!


Inaktiv
|
Horr
Thread-Ersteller


Wannabe poster




Beiträge: 25
# Antwort: 6 - 28.07.2012 um 21:49 Uhr
 
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.
160.
161.
162.
163.
164.
165.
166.
167.
168.
169.
170.
171.
172.
173.
174.
1. / 2. / ... 
 Array
(
    [
28964675] => Array
        (
            [
players] => Array
                (
                    [
0] => Array
                        (
                            [
hero] => npc_dota_hero_witch_doctor
                            
[name] => Hor 45519747
                            
[level] => 18
                            
[kills] => 9
                            
[deaths] => 6
                            
[assists] => 16
                            
[last_hits] => 59
                            
[denies] => 4
                            
[gold_per_min] => 349
                            
[xp_per_min] => 510
                            
[gold] => 857
                            
[account_id] => 45519747
                        
)

                    [
1] => Array
                        (
                            [
hero] => npc_dota_hero_nevermore
                            
[name] => WH.Walien 85135654
                            
[level] => 17
                            
[kills] => 4
                            
[deaths] => 8
                            
[assists] => 8
                            
[last_hits] => 174
                            
[denies] => 9
                            
[gold_per_min] => 476
                            
[xp_per_min] => 457
                            
[gold] => 1713
                            
[account_id] => 85135654
                        
)

                    [
2] => Array
                        (
                            [
hero] => npc_dota_hero_warlock
                            
[name] => Cuiabano 8678292
                            
[level] => 14
                            
[kills] => 4
                            
[deaths] => 9
                            
[assists] => 19
                            
[last_hits] => 57
                            
[denies] => 9
                            
[gold_per_min] => 326
                            
[xp_per_min] => 310
                            
[gold] => 2231
                            
[account_id] => 8678292
                        
)

                    [
3] => Array
                        (
                            [
hero] => npc_dota_hero_undying
                            
[name] => Kajii 81838516
                            
[level] => 19
                            
[kills] => 10
                            
[deaths] => 5
                            
[assists] => 16
                            
[last_hits] => 108
                            
[denies] => 7
                            
[gold_per_min] => 418
                            
[xp_per_min] => 534
                            
[gold] => 815
                            
[account_id] => 81838516
                        
)

                    [
4] => Array
                        (
                            [
hero] => npc_dota_hero_axe
                            
[name] => Hurley "Hugo" Reyes 81274050
                            
[level] => 15
                            
[kills] => 6
                            
[deaths] => 5
                            
[assists] => 10
                            
[last_hits] => 89
                            
[denies] => 0
                            
[gold_per_min] => 300
                            
[xp_per_min] => 368
                            
[gold] => 250
                            
[account_id] => 81274050
                        
)

                    [
128] => Array
                        (
                            [
hero] => npc_dota_hero_nyx_assassin
                            
[name] => Brad Pitt' - 40411769
                            [level] => 17
                            [kills] => 8
                            [deaths] => 9
                            [assists] => 14
                            [last_hits] => 58
                            [denies] => 7
                            [gold_per_min] => 248
                            [xp_per_min] => 469
                            [gold] => 1246
                            [account_id] => 40411769
                        )

                    [129] => Array
                        (
                            [hero] => npc_dota_hero_visage
                            [name] => Excuses - 38822742
                            [level] => 16
                            [kills] => 4
                            [deaths] => 7
                            [assists] => 16
                            [last_hits] => 66
                            [denies] => 3
                            [gold_per_min] => 235
                            [xp_per_min] => 391
                            [gold] => 1083
                            [account_id] => 38822742
                        )

                    [130] => Array
                        (
                            [hero] => npc_dota_hero_phantom_assassin
                            [name] => Fishdog - 75854226
                            [level] => 20
                            [kills] => 7
                            [deaths] => 5
                            [assists] => 12
                            [last_hits] => 127
                            [denies] => 2
                            [gold_per_min] => 346
                            [xp_per_min] => 596
                            [gold] => 1369
                            [account_id] => 75854226
                        )

                    [131] => Array
                        (
                            [hero] => npc_dota_hero_sniper
                            [name] => Vira - 12447705
                            [level] => 16
                            [kills] => 5
                            [deaths] => 7
                            [assists] => 13
                            [last_hits] => 120
                            [denies] => 7
                            [gold_per_min] => 271
                            [xp_per_min] => 383
                            [gold] => 1526
                            [account_id] => 12447705
                        )

                    [132] => Array
                        (
                            [hero] => npc_dota_hero_dark_seer
                            [name] => Eli - 77923715
                            [level] => 18
                            [kills] => 8
                            [deaths] => 5
                            [assists] => 13
                            [last_hits] => 99
                            [denies] => 0
                            [gold_per_min] => 274
                            [xp_per_min] => 499
                            [gold] => 929
                            [account_id] => 77923715
                        )

                )

            [higherLevel] => 20
            [higherKills] => 10
        )

)

The key 28964675 and is dynamic.


Zuletzt editiert von Horr am 28.07.2012 um 21:49 Uhr (1x Editiert)
Inaktiv
|
Jam2 ClanSphere Team


Highlander





Beiträge: 3291
# Antwort: 7 - 29.07.2012 um 12:12 Uhr
 
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
1. / 2. / ... 
<?php
$array 
= array(
                   
234234 => array(
                                    
'players' => array(
                                                        
=> array(
                                                                    
'hero' => 'adsf',
                                                                    
'name' => 'asdf'
                                                                
),
                                                        
123 => array(
                                                                    
'hero' => 'adsf2',
                                                                    
'name' => 'asdf2'
                                                                
)
                                                        )
                                )
               
               );
    
$i 0;
    foreach (
$array AS $key => $value)
    {
        
$data['something'][$i]['var'] = (int) $key// Output: 234234
        
$i2 0;
        foreach(
$value['players'] AS $key2 => $value2)
        {
            
$data['something'][$i]['somethingelse'][$i2]['hero'] = cs_secure($value2['hero']); // Output: adsf, adsf2
            
$data['something'][$i]['somethingelse'][$i2]['name'] = cs_secure($value2['name']); // Output: asdf, asdf2
        
}
    }


------------------
Gruß/ Best regards
Jam2

Nützliche Forumbeiträge/Codepastes: (Useful comments in our board / codepastes)
Template Switch for index.php
Board Navlist last posts

Edi: könnte man denn auch hier eine erweiterung einfügen?
Jam2: das web ist wie toyota.....
Edi: hö ?
Jam2: nichts ist unmöglich!


Inaktiv
|
Horr
Thread-Ersteller


Wannabe poster




Beiträge: 25
# Antwort: 8 - 29.07.2012 um 23:16 Uhr
Can you show me how i do in the .tpl? Im kind of dont understanding


Inaktiv
|
Jam2 ClanSphere Team


Highlander





Beiträge: 3291
# Antwort: 9 - 30.07.2012 um 19:47 Uhr
{loop:something}
{something:var}
{loop:somethingelse}
{somethingelse:hero}
{stop:somethingelse}
{stop:something}



btw. Where are you from?^^


------------------
Gruß/ Best regards
Jam2

Nützliche Forumbeiträge/Codepastes: (Useful comments in our board / codepastes)
Template Switch for index.php
Board Navlist last posts

Edi: könnte man denn auch hier eine erweiterung einfügen?
Jam2: das web ist wie toyota.....
Edi: hö ?
Jam2: nichts ist unmöglich!


Zuletzt editiert von Jam2 ClanSphere Team am 31.07.2012 um 20:21 Uhr (1x Editiert)
Inaktiv
|
Horr
Thread-Ersteller


Wannabe poster




Beiträge: 25
# Antwort: 10 - 07.08.2012 um 02:54 Uhr
Brasil, sorry for the bad english

Thanks for the help! I got it!


Inaktiv
|
Jam2 ClanSphere Team


Highlander





Beiträge: 3291
# Antwort: 11 - 08.08.2012 um 07:11 Uhr
Your english is good. I just ask because you write at midnight (for my time zone )


------------------
Gruß/ Best regards
Jam2

Nützliche Forumbeiträge/Codepastes: (Useful comments in our board / codepastes)
Template Switch for index.php
Board Navlist last posts

Edi: könnte man denn auch hier eine erweiterung einfügen?
Jam2: das web ist wie toyota.....
Edi: hö ?
Jam2: nichts ist unmöglich!


Inaktiv
|
Antworten: 11
Seite [1]


Sie müssen sich registrieren, um zu antworten.