smarty function assign php -


i have function in smarty checks if row called "mikaphotos" empty. if row empty, it's ok , doesnt happen anything, , if it's not empty..it takes value in $path variable. assin is:

$smarty->assign("mikaphotos", gettheimages("somepath",400), true); 

and gettheimages function is:

gettheimages($path,$width){  $dirname = $path; //the path  $images = glob($dirname."*.png");//get png images directory  foreach($images $image) {  echo '<img src="'.$dirname.'/'.$image.'" width="'.$width.'" /><br />';//echo images in somepath  } } 

now in file.tpl .. put:{$mikaphotos} , it's not working. think there problem in code, not know how that. please?

function assign in smarty assigns(!) value returned gettheimages function mikaphotos variable. so, gettheimages function should return string instead of echoing. example, like:

gettheimages($path,$width){     $result = '';     $dirname = $path; //the path     $images = glob($dirname."*.png");//get png images directory     foreach($images $image) {         $result .= '<img src="'.$dirname.'/'.$image.'" width="'.$width.'" /><br />';     }      return $result;    // return html images string }     

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

how to prompt save As Box in Excel Interlop c# MVC 4 -

xslt 1.0 - How to access or retrieve mets content of an item from another item? -