Je viens de découvrir votre forum, et je pense que vous pourrez m'aider.
En effet, je gère un forum ET un site.
Je souhaite afficher sur la home du dit site les 5 derniers posts (et non les 5 derniers topics) du forum.
J'ai trouvé le code suivant, mais celui-ci ne m'affiche que les 5 derniers topics créés :
- Code: Tout sélectionner
(...)
<?php
$auth->acl($user->data);
$user->setup();
$forum_id = request_var('forum_id', 0);
$where = ($forum_id) ? "WHERE forum_id=$forum_id" : '';
$sql = 'SELECT forum_id, topic_id, topic_time, topic_title, topic_views, topic_replies, topic_poster, topic_first_poster_name, topic_first_poster_colour, topic_last_post_id, topic_last_poster_id, topic_last_poster_name, topic_last_poster_colour, topic_last_post_time FROM ' . TOPICS_TABLE . $where . ' ORDER BY topic_last_post_time DESC ' . ' LIMIT 0 , 5 ';
$result = $db->sql_query($sql);
echo '<table width="100%" class="newsforum">';
echo '<tr>';
echo '<th align="left">Sujets</th>';
echo '<th align="center">Réponses</th>';
echo '<th align="center">Vus</th>';
echo '<th align="right">Dernier message</th>';
echo '</tr>';
$i=0;
while($row = $db->sql_fetchrow($result))
{
$row['topic_title'] = utf8_decode($row['topic_title']);
$row['topic_first_poster_name'] = utf8_decode($row['topic_first_poster_name']);
$row['topic_last_poster_name'] = utf8_decode($row['topic_last_poster_name']);
$topic_id = $row['topic_id'];
$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($row['forum_id']) ? $row['forum_id'] : $forum_id) . '&t=' . $topic_id);
//$row_colour = ($i % 2) ? '#FFFFCC' : '#99FFFF';
//echo '<tr bgcolor="' . $row_colour .'">';
echo '<tr>';
echo '<td align="left">';
echo '<a href="' . $view_topic_url . '">' . censor_text($row['topic_title']) . '</a><br />';
echo $user->lang['POST_BY_AUTHOR'] . ' ' . get_username_string('full', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']);
echo ' ' . $user->lang['POSTED_ON_DATE'] . ' ' . $user->format_date($row['topic_time']) . '</td>';
echo '<td align="center">' . $row['topic_replies'] . '</td>';
echo '<td align="center">' . $row['topic_views'] . '</td>';
echo '<td align="left">' . $user->lang['POST_BY_AUTHOR'] . ' ' . get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']);
echo ' <a href="' . $view_topic_url . '&p=' . $row['topic_last_post_id'] . '#p' . $row['topic_last_post_id'] . '"><img src="' . $phpbb_root_path . 'styles/' . $user->theme['imageset_path'] . '/imageset/icon_topic_latest.gif" border="0" alt="' . $user->lang['VIEW_LATEST_POST'] . '" title="' . $user->lang['VIEW_LATEST_POST'] . '" />' . '</a><br />';
echo $user->lang['POSTED_ON_DATE'] . ' ' . $user->format_date($row['topic_last_post_time']) . '</td>';
echo '</tr>';
$i++;
}
echo '</table>';
?>
(...)
Pouvez-vous m'aider ?

Français |
Anglais
