Affichage des derniers topics du forum sur le site

WRInaute impliqué
Bonjour!

Voila, pour afficher les derniers topics de mon forum phpbb sur la page d'accueil de mon site j'utilise ce code mais il n'exclue pas le forum privé visible par les modérateur.

Y'a t-il un moyen de le modifier en lui faisant vérifier la valeur du champ "forum_id" dans la table "phpbb_topics" et si celle ci est par exemple égale à 5 (forum privé), il n'affiche rien et si c'est une autre valeur il affiche le contenu ?

Code:
<?php
     // www.phpBB-SEO.com SEO TOOLKIT BEGIN
     include('../forum/phpbb_seo/phpbb_seo_class.php');
     $phpbb_seo = new phpbb_seo();
     $phpbb_seo->seo_path['phpbb_script'] = 'forum/';
     $phpbb_seo->seo_path['root_url'] = 'http://www.blind-guardian.fr/';
     $phpbb_seo->seo_path['phpbb_url'] = $phpbb_seo->seo_path['root_url'] . $phpbb_seo->seo_path['phpbb_script'];
     $phpbb_seo->seo_url['user'] = $this->seo_static['user'] = 'membre'; 
     // www.phpBB-SEO.com SEO TOOLKIT END
     
     
     // Connexion à la BDD
     $db_link = @mysql_connect(***,***,***);
     mysql_select_db(***);
        
     // Sélection des 5 derniers posts
     
     $sql = "SELECT TP.topic_id, TP.topic_title, PT.post_text, PST.post_time, PST.poster_id, PST.post_username, US.username
     
     FROM phpbb_topics TP, phpbb_posts_text PT, phpbb_posts PST, phpbb_users US
     
     WHERE PT.post_id = TP.topic_first_post_id
     AND PST.post_id = TP.topic_first_post_id
     AND US.user_id = TP.topic_poster
     
     GROUP BY TP.topic_id
     ORDER BY TP.topic_id DESC
     LIMIT 5";
      
     $req = mysql_query($sql) or die(mysql_error());
     
     // Boucle d'affichage du post
     while($db_data = mysql_fetch_assoc($req)) {
     
     // Titre du post
     // www.phpBB-SEO.com SEO TOOLKIT BEGIN
          $post_title = "<a href=\"" . $phpbb_seo->seo_path['phpbb_url'] . $phpbb_seo->format_url($db_data['topic_title']) . $phpbb_seo->seo_delim['topic'] . $db_data['topic_id'] . $phpbb_seo->seo_ext['topic'] . "\">" . $db_data['topic_title'] . "</a>";
          $post_title = preg_replace("(´)","'",$post_title );
          $post_title = preg_replace("(à)","&agrave;",$post_title );
          $post_title = preg_replace("(â)","&acirc;",$post_title );
          $post_title = preg_replace("(ä)","&auml;",$post_title );
          $post_title = preg_replace("(ç)","&ccedil;",$post_title );
          $post_title = preg_replace("(è)","&egrave;",$post_title );
          $post_title = preg_replace("(é)","&eacute;",$post_title );
          $post_title = preg_replace("(ê)","&ecirc;",$post_title );
          $post_title = preg_replace("(ë)","&euml;",$post_title );
          $post_title = preg_replace("(î)","&icirc;",$post_title );
          $post_title = preg_replace("(ï)","&iuml;",$post_title );
          $post_title = preg_replace("(ù)","&ugrave;",$post_title );
          $post_title = preg_replace("(ü)","&uuml;",$post_title );
          $post_title = preg_replace("(û)","&ucirc;",$post_title );
          $post_title = preg_replace("(ô)","&ocirc;",$post_title );
          $post_title = preg_replace("(ö)","&ouml;",$post_title );
          $post_title = preg_replace("(«)","&laquo;",$post_title );
          $post_title = preg_replace("(»)","&raquo;",$post_title );
     // www.phpBB-SEO.com SEO TOOLKIT END
     
     // Extrait du post
     $post = $db_data['post_text'];
     $max_caracteres = 200; 
        if (strlen($post)>$max_caracteres) {
        $max_caracteres=strrpos(substr($post, 0, $max_caracteres), " ");
        $post = substr($post, 0, $max_caracteres);
        $post .= " (...)";
     }
     
           
     $post = preg_replace("(\[.*\])U","",$post );
     $post = preg_replace("(´)","'",$post );
     $post = preg_replace("(à)","&agrave;",$post );
     $post = preg_replace("(â)","&acirc;",$post );
     $post = preg_replace("(ä)","&auml;",$post );
     $post = preg_replace("(ç)","&ccedil;",$post );
     $post = preg_replace("(è)","&egrave;",$post );
     $post = preg_replace("(é)","&eacute;",$post );
     $post = preg_replace("(ê)","&ecirc;",$post );
     $post = preg_replace("(ë)","&euml;",$post );
     $post = preg_replace("(î)","&icirc;",$post );
     $post = preg_replace("(ï)","&iuml;",$post );
     $post = preg_replace("(ù)","&ugrave;",$post );
     $post = preg_replace("(ü)","&uuml;",$post );
     $post = preg_replace("(û)","&ucirc;",$post );
     $post = preg_replace("(ô)","&ocirc;",$post );
     $post = preg_replace("(ö)","&ouml;",$post );
     $post = preg_replace("(«)","&laquo;",$post );
     $post = preg_replace("(»)","&raquo;",$post );
     $poster = "<a href=\"" . $phpbb_seo->seo_path['phpbb_url'] . $phpbb_seo->seo_static['user'] . $db_data['poster_id'] . $phpbb_seo->seo_ext['user'] . "\" class=\"nav\" >".$db_data['username']."</a>";
     $post_time = strftime("%A %e %B &agrave; %H:%M", $db_data['post_time']+(0));
     
     echo "<p>$post_title par $poster<br />$post_time<br />$post</p>";
     
     }
     ?>
 
WRInaute accro
Ptet rajouter dans ta requête SQL ce qu'il faut ?

Si tu veux pas afficher les posts prevenant du idforum 1 et 2

Code:
AND TP.forum_id NOT IN (1,2)

ou à tester pour ton cas :
Code:
AND TP.forum_id <> 5

ou en prenant juste ceux des forums que tu veux

Code:
AND TP.forum_id IN (3,4,6)

?
 
Discussions similaires
Haut