Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/09/2006, 15:02
Avatar de peperoni
peperoni
 
Fecha de Ingreso: febrero-2005
Mensajes: 24
Antigüedad: 19 años, 3 meses
Puntos: 0
Ejemplo de Smarty

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::..