>>
Site Map
>>
Forums
>>
Blocks
Forum module - topics in forum:
Blocks - Having problems with a block? Code doesn't work, get help here.
Forum Latest Topic
Want to know if there is a way to highlight new topic in this block for 10 days or so... That way members could see the new topics highlighted.
<?php
/************************************************************************/
/* PHP-NUKE: Web Portal System */
/* =========================== */
/* */
/* Copyright (c) 2003 James Hoadley (HyneeHoadley@Hotmail.com) */
/*
http://phpnuke.org */
/* */
/* An attempt to improve on block-Forums.php */
/* */
/* */
/* Issued under GPL. If you host this file, please contact the author. */
/* */
/* */
/************************************************************************/
if (eregi("block-Forum_Latest_Topics.php", $_SERVER['PHP_SELF'])) {
Header("Location: index.php");
die();
}
global $prefix, $db, $sitename;
//Number of topics to show.
$fltNrTopics = 10;
//flpContentPrefix goes before output, flpContentSuffix after.
$fltContentPrefix = "";
$fltContentSuffix = "<br><center><a href=\"modules.php?name=Forums\">
$sitename Forums</a><br><br></center>";
//$fltNormalMode selects query type.
//$fltNormalMode=false selects a more intensive query that is more robust
$fltNormalMode = true;
$content = $fltContentPrefix;
if ($fltNormalMode) {
$sql = "SELECT ".$prefix."_bbposts.forum_id AS forum_id, ".$prefix."_bbposts.topic_id AS topic_id, ".$prefix."_bbtopics.topic_title AS topic_title "
."FROM ".$prefix."_bbposts, ".$prefix."_bbtopics "
."WHERE (".$prefix."_bbposts.topic_id = ".$prefix."_bbtopics.topic_id) "
."ORDER BY ".$prefix."_bbposts.post_time DESC LIMIT ".max($fltNrTopics*2,10);
$result = $db->sql_query($sql);
$Topic_IDs_Used = array();
$Topics_Printed = 0;
while ( ($row = $db->sql_fetchrow($result)) && ($Topics_Printed < $fltNrTopics) ){
$forum_id = $row['forum_id'];
$topic_id = $row['topic_id'];
$topic_title = $row['topic_title'];
if (!in_array($topic_id,$Topic_IDs_Used)) {
$Topics_Printed = array_push($Topic_IDs_Used,$topic_id);
//Now have topic_id and topic_title, ordered by last post time.
//Next, do authorization to read check.
$sql_auth = "SELECT auth_view, auth_read FROM ".$prefix."_bbforums WHERE forum_id='$forum_id'";
$result_auth = $db->sql_query($sql_auth);
$row_auth = $db->sql_fetchrow($result_auth);
$auth_view = $row_auth[auth_view];
$auth_read = $row_auth[auth_read];
if (($auth_view < 2) OR ($auth_read < 2)) {
$content .= "<img src=\"images/arrow.gif\" border=\"0\" alt=\"\" title=\"\" width=\"9\" height=\"9\"> <a href=\"modules.php?name=Forums&file=viewtopic&t=" . $topic_id . "\">" . $topic_title . "</a><br>";
}
}
}
} else {
$Topic_IDs_Used = array();
$Topics_Printed = 0;
$Start_Limit = 0;
$sql = "SELECT ".$prefix."_bbposts.forum_id AS forum_id, ".$prefix."_bbposts.topic_id AS topic_id, ".$prefix."_bbtopics.topic_title AS topic_title "
."FROM ".$prefix."_bbposts, ".$prefix."_bbtopics "
."WHERE (".$prefix."_bbposts.topic_id = ".$prefix."_bbtopics.topic_id) "
."ORDER BY ".$prefix."_bbposts.post_time DESC LIMIT $Start_Limit,$fltNrTopics";
$result = $db->sql_query($sql);
$Start_Limit+=$fltNrTopics;
while (( $db->sql_numrows($result) > 0 ) && ($Topics_Printed < $fltNrTopics) ) {
while ( ($row = $db->sql_fetchrow($result)) && ($Topics_Printed < $fltNrTopics) ) {
$forum_id = $row['forum_id'];
$topic_id = $row['topic_id'];
$topic_title = $row['topic_title'];
if (!in_array($topic_id,$Topic_IDs_Used)) {
$Topics_Printed = array_push($Topic_IDs_Used,$topic_id);
//Now have topic_id and topic_title, ordered by last post time.
//Next, do authorization to read check.
$sql_auth = "SELECT auth_view, auth_read FROM ".$prefix."_bbforums WHERE forum_id='$forum_id'";
$result_auth = $db->sql_query($sql_auth);
$row_auth = $db->sql_fetchrow($result_auth);
$auth_view = $row_auth[auth_view];
$auth_read = $row_auth[auth_read];
if (($auth_view < 2) OR ($auth_read < 2)) {
$content .= "<img src=\"images/arrow.gif\" border=\"0\" alt=\"\" title=\"\" width=\"9\" height=\"9\"> <a href=\"modules.php?name=Forums&file=viewtopic&t=" . $topic_id . "\">" . $topic_title . "</a><br>";
}
}
}
$sql = "SELECT ".$prefix."_bbposts.forum_id AS forum_id, ".$prefix."_bbposts.topic_id AS topic_id, ".$prefix."_bbtopics.topic_title AS topic_title "
."FROM ".$prefix."_bbposts, ".$prefix."_bbtopics "
."WHERE (".$prefix."_bbposts.topic_id = ".$prefix."_bbtopics.topic_id) "
."ORDER BY ".$prefix."_bbposts.post_time DESC LIMIT $Start_Limit,$fltNrTopics";
$result = $db->sql_query($sql);
$Start_Limit+=$fltNrTopics;
}
}
$content .= $fltContentSuffix;
?>
No there isn't the block pulls the newest post from the forums as they come. To do this would probably require a complete rewrite of the forums as well as the block.