Voici le code que j'utilise pour afficher les derniers posts de mon forum phpbb3 sur ma page index du site (et non du forum).
Tout marche bien sauf deux choses :
- l'adapation avec le mod rewrite
- et le lien pour atteindre le dernier post. Quand il y a plus d'une page le lien n'est plus reconnu car le nombre de page n'est pas appliqué.
Pouvez-vous m'aider à résoudre ces problèmes ? Merci !
- Code: Tout sélectionner
define('IN_PHPBB', TRUE);
$phpbb_root_path = 'forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
$exclude_forums = array(3,110,111,112,113,114,116,117,118,156,999);
$sql_array = array(
'SELECT' => 't.topic_poster,t.topic_views,t.topic_replies,t.topic_id, t.topic_title, t.topic_last_post_id, t.forum_id, p.post_id, p.poster_id, p.post_time, u.user_id, u.username',
'FROM' => array(
POSTS_TABLE => 'p',
TOPICS_TABLE => 't',
USERS_TABLE => 'u'
),
'WHERE' => $db->sql_in_set('t.forum_id', $exclude_forums, true) . '
AND t.topic_id = p.topic_id AND p.post_id = t.topic_last_post_id AND p.poster_id = u.user_id',
'ORDER_BY' => 'p.post_id DESC'
);
$sql = $db->sql_build_query('SELECT', $sql_array);
$result = $db->sql_query_limit($sql, 10, 0);
while ($row = $db->sql_fetchrow($result))
{
$date_last_post = date("d.m.Y H:i:s",$row['post_time']);
echo '<li class="gras">» <a href="' . $phpbb_root_path . 'viewtopic.php?t=' . $row['topic_id'] . '">' . (utf8_decode($row['topic_title'])) . '</a> ('.$row['topic_replies'].' réponse';
if($row['topic_replies']>1) echo "s";
echo ')<br />'.utf8_decode($row['username']).', '.$date_last_post.' <a href="' . $phpbb_root_path . 'viewtopic.php?t=' . $row['topic_id'] . '#p'.$row['topic_last_post_id'].'" title="Aller au dernier message de ce sujet"><img src="forum/styles/prosilver/imageset/icon_topic_latest.gif" width="11" height="9" alt="Aller au dernier message de ce sujet" style="display:inline;" /></a></li>';
}

Français |
Anglais


