Estoy tratando de desarrollar un ABM de noticias basado en los
templates de Smarty.
Si bien el Alta, es exitosa, tengo problemas al mostrarlos.
El modo debug de Smarty, me muestra que *si* toma los datos de la DB,
pero no se como mostrarlos.
Código:
y para leerlos uso:Array (1) 0 => Array (7) id => "1" Titulo => "Noticia1" Copete => "Copete1" Cuerpo => "Cuerpo1" Foto => "isla.jpg" Seccion => "Seccion1" Fecha => "2007-06-22"
Código:
para mostrar:<?php require('include.php'); $sql = 'SELECT * '; $sql .= 'FROM `news` '; $sql .= 'ORDER BY `id` DESC LIMIT 0, 5'; $result = mysql_query($sql) or die("Query failed : " . mysql_error()); while ($line = mysql_fetch_assoc($result)) { $value[] = $line; } $smarty->assign('noticias', $value); /* echo "<pre>"; print_r($noticias); echo "</pre>"; */ $smarty->display('index.tpl'); ?>
Código:
Cual es la forma correcta de pedir que muestre los datos? <table border="1" align="center" > {section name=mostrar loop=$noticias} <tr> <td width="43%" rowspan="2"><div align="center"><img src="00img/img_default.JPG" width="100" height="100" hspace="5" vspace="5" id="Noticia_Imagen"></div></td> <td width="44%" height="91" class="Noticia_Titulo">{$noticias[mostrar][Copete]}{$smarty.section.mostrar.index}</td> </tr> <tr> <td class="Noticia_Copete">{$noticias[mostrar][Copete]}Copete</td> </tr> <tr> <td colspan="2" class="Noticia_Cuerpo">{$noticias[mostrar][Cuerpo]}Cuerpo <a href="#" onClick="showHideLayers(NoticiaLayer,'','show');">[+info] </a></td> </tr> {/section} </table>