Estoy tratando de entender la forma de trabajo de Smarty modificando algunos ejemplos, pero no logro hacer lo que me propongo.
Tengo un arreglo con varios elementos, lo que quiero es imprimir los elementos del arreglo usando una plantilla.
Código PHP:
<?php
// load Smarty library
require('../libs/Smarty.class.php');
$smarty = new Smarty;
$smarty->template_dir = 'C:\AppServ\www\test\smarty\templates';
$smarty->compile_dir = 'C:\AppServ\www\test\smarty\templates_c';
$smarty->config_dir = 'C:\AppServ\www\test\smarty\configs';
$smarty->cache_dir = 'C:\AppServ\www\test\smarty\cache';
$color = array('black','white','orange');
$siguiente = current($color);
while ($siguiente!=false){
$smarty->assign('name',current($color));
$siguiente=next($color);
}
//$smarty->assign('name','Ned');
$smarty->display('../index.tpl');
?>
y esta es la plantilla
Código HTML:
{* Smarty *}
Color ahora es , {$name}!<br>
Solo me imprime el ultimo elemento
Saludos::..