Little problem when looping sections
| From: | Luc Saint-Elie | Date: | Fri, 11 May 2001 20:33:42 +0000 |
| Subject: | Little problem when looping sections | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-748@lists.php.net to get a copy of this message | ||
Hello
The context
-----------------
I'm building a little publishing system that takes an XML file, transform it in an array and send it via smarty to a template.. classical
The function
---------------------
By default the last story is displayed in full and the other have just their title and a "read more" link
When the user click on a "read more" link its the related story that is displayed in full other been displayed with just the title and so on..
My problem is that I would like the "full display" to be always at the top of the page and the "title diplay" under
I have currently a working system but with the big story been .. where it was when displayed as a simple title
Any tip ?
Luc
--------------- THE php FILE -----------------
[...]
$array_news= array();
//print $xml["hans"][0]->attributes[0]["size"]; # where "size" was an attr name
for($i=0;$i<sizeof($news['newsfeed_story']);$i++) {
array_push ($array_news, array('number'=>$news['newsfeed_story'][$i]->attributes[0]["number"],
date'=>$news['newsfeed_story'][$i]->date[0],
'titre'=>$news['newsfeed_story'][$i]->titre[0],
'chapo'=>$news['newsfeed_story'][$i]->chapo[0],
'text'=>$news['newsfeed_story'][$i]->text[0]));
}
$tpl->assign('suite',$action);
$tpl->assign('array_news', $array_news);
$tpl->assign('op','actu');
$tpl->display('index.tpl');
[...]
-------------------------------------------------------
-----------THE .tpl FILE-----------------
<table width="100%" border="0" align="center">
{section name=actu loop=$array_news}
{if $suite eq $array_news[actu].number}
<tr>
<td colspan="2" align="left">
<B>{$array_news[actu].titre}</B><br><hr>
</td>
</tr>
<tr>
<td colspan="2">
{$array_news[actu].chapo}<p>{$array_news[actu].text}
</td>
</tr>
<tr>
<td align="left"><a href="actu.php?action={$array_news[actu].number}">[Lire...]</a> </td>
<td align="right">Posté le : {$array_news[actu].date}</td>
</tr>
<tr><td colspan="2"> </td></tr>
{else}
<tr>
<td align="left"><a href="actu.php?action={$array_news[actu].number}">[Lire...]</a> </td>
<td width="90%" align="left"><B>{$array_news[actu].titre}</B> </td>
</tr>
{/if}
{/section}
</table>
-------------------------------------------------------------------------------------------------