boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Lister les posts d'1 seule catégorie (paramétrable)

 
Post new topic   Reply to topic    boardom Forum Index -> Aide en français
View previous topic :: View next topic  
Author Message
Sansnom



Joined: 31 Jan 2002
Posts: 94
Location: Paris

PostPosted: Wed May 14, 2003 9:26 am    Post subject: Lister les posts d'1 seule catégorie (paramétrable) Reply with quote

Si vous voulez lister les posts d'1 seule catégorie en controlant le nombre de posts affichés, utilisez cette fonction :

Code:

<?

include("b2config.php");
include("blog.header.php");

function uniliste($cat = "", $avant = "", $apres = "", $limite)  {
global $tableposts, $querycount; 
$result=mysql_query("SELECT ID, post_title FROM $tableposts WHERE post_category = $cat ORDER BY post_date DESC LIMIT $limite");
$querycount++;

   while ($data = mysql_fetch_row($result)) {
          echo "<a href=http://www.sansfin.com/index.php?p=$data[0] target=_blank>";
        echo $avant.stripslashes($data[1]).$apres;
        echo "</a>";
}
}


?>


Pour l'appeler (et la paramétrer) :

Code:
 <?php uniliste("9","<span class=addition>","</span><br>", "25"); ?>


Dans cet exemple, je veux les titres des 25 derniers posts appartenant à la catégorie 9. Et je formate le texte à l'aide d'une feuille de style (span).

J'ai mixé 2 fonctions différentes trouvées sur le forum anglophone pour pondre celle-ci.

Celle-ci : http://tidakada.com/board/viewtopic.php?p=14527
et celle-là : http://tidakada.com/board/viewtopic.php?t=1046&postdays=0&postorder=asc&highlight=headlines&start=15

Voilà. Comme je suis un peu débile, j'y ai passé 4 heures, alors j'espère épargner le même nombre d'heures à quelqu'un d'autre Very Happy
_________________
http://www.sansfin.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> Aide en français All times are GMT + 1 Hour
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 2 © 2001, 2002 phpBB Group