|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
yaz123 Smarty n00b
Joined: 06 Nov 2008 Posts: 3
|
Posted: Tue Nov 11, 2008 10:27 am Post subject: integrer un while dans smarty |
|
|
bonjour;
Dans mon fichier "index.php" j'ai un while qui me ressort des articles :
Code: | // setting results
$data_rows = array();
while ($row_Recordset = mysql_fetch_assoc($Recordset))
{
$row_Recordset['ItemTitleUrl'] = code_url($row_Recordset['ItemTitle']);
$row_Recordset['Date'] = date('l d-m-Y h:i', strtotime($row_Recordset['ItemAddedTime']));
$data_rows[] = $row_Recordset;
}
mysql_free_result($Recordset);
//
$smarty->assign('data_rows', $data_rows); |
et dans mon template voici ce que je mets :
Code: | {section name=key loop=$data_rows[main_key]}
<a href="page.php?recordID={$data_rows[main_key][key].itemID}">{$data_rows[main_key][key].ItemTitle}</a>
<small style="display:inline;color:green">
{$data_rows[main_key][key].Date}
</small>
<br />
{/section} |
Ma page reste vide
Comment faire pour ressortir mes données sur le template ?
Au passage, Y a t il vraiment de gros risques à faire directement un include avec {php} mon script {/php} dans mon template ? Pourquoi cela est il fortement deconseillé dans la documentation de smarty ?
Merci
Yaz |
|
Back to top |
|
gtraxx Smarty Regular
Joined: 08 Jan 2008 Posts: 56
|
Posted: Tue Nov 11, 2008 3:47 pm Post subject: |
|
|
je vous recommande de tester d'abord si votre tableau contient bien quelque chose.
un petit print_r ou var_dump ou encore en utilisant le debug smarty
c'est simplement un souci avec le tableau |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|