• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

xen foreach

DroidHost

Well-known member
#1
I want to use foreach statment but my mind is locked for now
so I want some help here

I have an array
I want the template to enter a loop and fill the variable with diff value
Somethins like
PHP:
array (data=>array( 'names' => array('ali ','james')))
___
in the template if I am correct which I don't

Code:
<xen:foreach loop="$names"    value="$name">

        {$name}

</xen:foreach>
 

Marc

Well-known member
#2
Depending on what you have sent to the template would it not be something like the following:

Code:
<xen:foreach loop="$names"    value="$name">
{$name.name}
</xen:foreach>
Would need to see what your actually sending to the template

EDIT: Ignore that, didnt read your post properly LOL
 

DroidHost

Well-known member
#4
PHP:
            <xen:foreach loop="$data"    value="$data">
                <a class="externalLink" rel="nofollow" target="_blank" href="{$data.url}"><img src="{$data.img}" alt="" title="{$data.caption}" /></a>
              </xen:foreach>
I dont know ... maybe if I used it in PHP code level .. will solve this issue
I will think of something !
 

DroidHost

Well-known member
#7
the array :
PHP:
        $data = array(
        'bannars'=>array(
            '1'=>
            array(
             .........
            ),
            '2'=>
            array(
             .........
            ),
            '3'=>
            array(
             .........
            ),
            '4'=>
            array(
            ........
            ),
            '5'=>
            array(
             ...
            ),
        ));
then send $data ...

after that in the template it will work !
HTML:
            <xen:foreach loop="$data"    value="$data">
                <a class="externalLink" rel="nofollow" target="_blank" href="{$data.url}"><img src="{$data.img}" alt="" title="{$data.caption}" /></a>
              </xen:foreach>