Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

integrer un while dans smarty

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French
View previous topic :: View next topic  
Author Message
yaz123
Smarty n00b


Joined: 06 Nov 2008
Posts: 3

PostPosted: Tue Nov 11, 2008 10:27 am    Post subject: integrer un while dans smarty Reply with quote

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
View user's profile Send private message
gtraxx
Smarty Regular


Joined: 08 Jan 2008
Posts: 56

PostPosted: Tue Nov 11, 2008 3:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: French All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP