 |
boardom b2 message board
|
View previous topic :: View next topic |
Author |
Message |
lune
Joined: 01 Oct 2003 Posts: 24
|
Posted: Wed Oct 01, 2003 6:50 am Post subject: affichage des derniers commentaires |
|
|
Bonjour tout le monde
Je souhaiterais afficher les derniers commentaires
voir exemple : http://www.auberge-irlandaise.net/
Dernières réactions
merci à vous |
|
Back to top |
|
 |
archiguy
Joined: 05 Mar 2003 Posts: 47
|
Posted: Wed Oct 01, 2003 6:16 pm Post subject: |
|
|
crée un fichier avec ca dans /include : lastcomments.php :
Code: |
<?php
//By Michael H. Park (http://www.MichaelPark.net)
function latestcomments($number = 10, $commentlength = 20, $authorstr = ' said...', $replacestr = '[...]', $show_date = 1, $show_time = 1) {
global $tableposts, $tablecomments, $siteurl, $querycount;
global $querystring_start, $querystring_equal, $querystring_separator;
//strings you wish to exclude... to add more, use $excludeaway[] = "string";
$excludearray[] = ":cool:";
$excludearray[] = ":mad:";
$excludearray[] = ":oops:";
$excludearray[] = ":evil:";
$excludearray[] = ":twisted:";
$excludearray[] = ":roll:";
$excludearray[] = ":wink:";
$excludearray[] = ":idea:";
$excludearray[] = ":arrow:";
$excludearray[] = ":cry:";
$excludearray[] = ":razz:";
$excludearray[] = ":neutral:";
$excludearray[] = ":mrgreen:";
$excludearray[] = ":shock:";
$excludearray[] = ":eek:";
$excludearray[] = ":lol:";
$excludearray[] = ":grin:";
$excludearray[] = ":sad:";
$excludearray[] = ":smile:";
$joinquery = "SELECT ID, comment_ID, comment_author, comment_author_url, comment_content";
//for date/time formatting, see www.mysql.com/doc/en/Date_and_time_functions.html
if ($show_date == 1) {
$joinquery .= ", DATE_FORMAT(comment_date, '%b. %D, %Y ') AS date";
}
if ($show_time == 1) {
$joinquery .= ", TIME_FORMAT(comment_date, '%l:%i %p') AS time";
}
$joinquery .= " FROM $tableposts LEFT JOIN $tablecomments ON ID = comment_post_ID " .
" WHERE comment_content NOT LIKE '%<trackback />%' AND comment_content NOT LIKE '%<pingback />%' " .
" AND comment_content != '' " .
" ORDER BY comment_date DESC LIMIT $number";
$joinresult = mysql_query($joinquery) or die(mysql_error());
$querycount++;
while ($rows = mysql_fetch_array($joinresult)) {
$postID = $rows["ID"];
$commentID = $rows["comment_ID"];
$commentauthor = stripslashes($rows["comment_author"]);
$commentauthorurl = $rows["comment_author_url"];
$commentcontent = strip_tags(stripslashes($rows["comment_content"]));
if (!empty($excludearray)) {
foreach ($excludearray AS $exclude) {
$commentcontent = str_replace($exclude, '', $commentcontent);
}
}
if ($show_date == 1) {
$commentdatetime = $rows["date"];
}
if ($show_time == 1) {
if ($show_date == 1) {
$commentdatetime .= ' @ ';
}
else {
$commentdatetime = '@ ';
}
$commentdatetime .= $rows["time"];
}
echo "<p>";
if (strlen($commentcontent) > $commentlength) {
$link = ' <a href="'.$siteurl.'/'.$querystring_start.'p'.$querystring_equal.$postID.$querystring_separator.'c'.$querystring_equal.'1'.$querystring_separator.'more'.$querystring_equal.'1#c'.$commentID.'">'.$replacestr.'</a>';
$commentcontent = substr_replace($commentcontent, $link, $commentlength);
}
else {
$link = ' <a href="'.$siteurl.'/'.$querystring_start.'p'.$querystring_equal.$postID.$querystring_separator.'c'.$querystring_equal.'1'.$querystring_separator.'more'.$querystring_equal.'1">[Post]</a>';
$commentcontent .= $link;
}
if (empty($commentauthorurl) || strlen($commentauthorurl) < 12) {
echo $commentauthor.$authorstr;
}
else {
echo '<a href="'.$commentauthorurl.'" target="_blank">'.$commentauthor.'</a>'.$authorstr;
}
echo "\n";
echo $commentcontent."</p>\n";
if ($show_date == 1 || $show_time == 1) {
echo "<p><span style = \"font-size:9px\">on ".$commentdatetime."</span></p><br>\n\n";
}
else {
echo "<br>\n";
}
}
}
?>
|
ensuite tu n'as plus qu'a rajouter ca ou tu veux:
Code: |
<?php /* Don't remove this line, it calls the b2 function files ! */ $blog=1; include ("blog.header.php"); ?>
<!-- nb commentaire, taille commentaire , separateur , fin comment , date , time-->
<?php latestcomments(15, 10, " : ", "[...]", 0, 0); ?>
|
mail moi si tu n'y arrive pas ou mieux, laisse moi un message sur mon blog
bon courage _________________ Archiguy
http://www.archiguy.com
Mais qu'est ce qu'il m'arrive? |
|
Back to top |
|
 |
lune
Joined: 01 Oct 2003 Posts: 24
|
Posted: Wed Oct 01, 2003 8:56 pm Post subject: |
|
|
super gentil à toi Archyguy pour avoir mis la totalité du code
vu que je ne suis pas bien douée
si j'ai un blème je te mailerais
un grand merci
 |
|
Back to top |
|
 |
Doc.Fusion
Joined: 19 May 2003 Posts: 25
|
Posted: Sun Oct 12, 2003 11:42 am Post subject: |
|
|
Chez free, la fonction me fait : "The SELECT would examine too many records and probably take a very long time. Check your WHERE and use SET OPTION SQL_BIG_SELECTS=1 if the SELECT is ok"
Comment je fixe ça ? Je dois rajouter le SET OPTION.... dans la requête ?
|
|
Back to top |
|
 |
archiguy
Joined: 05 Mar 2003 Posts: 47
|
Posted: Tue Oct 21, 2003 12:04 am Post subject: |
|
|
oui probablement.... _________________ Archiguy
http://www.archiguy.com
Mais qu'est ce qu'il m'arrive? |
|
Back to top |
|
 |
|
|
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
|