1
xsell
Assign for loop with Smarty
  • 2010/2/20 6:10

  • xsell

  • Quite a regular

  • Posts: 245

  • Since: 2008/9/2 1


Hello

this is Simple Code i use , it Prints Ball Image equal to $image Value ..

if $image=3 that mean the Image will be printed 3 times ..

i need to assing it to Smarty to use it in template.
$image =2;
for(
$i=1;$i<=$image$i++){

echo 
'<img src="'.XOOPS_ROOT_PATH.'/modules/test/images/ball.png" />';

}

i could do it by Number Just like
$xoopsTpl->assign('image'$image);
this will print the Number .. but i need to print out the Image . so i tried something like
$xoopsTpl->assign('image''<img src="'.XOOPS_ROOT_PATH.'/modules/test/images/ball.png" alt="" />');

but this printed Out only One image regards to $image Value..

any idea?
Thx

2
trabis
Re: Assign for loop with Smarty
  • 2010/2/20 6:47

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


$count =2
$image '';
for(
$i=1;$i<=$count$i++){ 

$image .= '<img src="'.XOOPS_ROOT_PATH.'/modules/test/images/ball.png" />'

}
$xoopsTpl->assign('image'$image);




3
xsell
Re: Assign for loop with Smarty
  • 2010/2/20 7:10

  • xsell

  • Quite a regular

  • Posts: 245

  • Since: 2008/9/2 1


Thank You Trabis .. Perfect ..!