1
Hello,
I wanted to add "Latest Post" and "Newest Thread" to the newbb index page where the forums are listed. Here is what I added, please rigorize if needed.
In newbb_index.html (added to the Last Post cell):
le="color: #000000"><?php Newest Thread: <a href="viewtopic.php?topic_id=<{$forum.forum_newest_thread_id}>&forum=<{$forum.forum_id}>"><{$forum.forum_newest_thread|truncate:25:"...":true}></a> by <{$forum.forum_newest_thread_creator}> <br /> Last Post: <a href="viewtopic.php?topic_id=<{$forum.forum_lastpost_id}>&forum=<{$forum.forum_id}>#forumpost<{$forum.forum_lastpost_thread_id}>">Re: <{$forum.forum_lastpost_thread|truncate:25:"...":true}></a> by <{$forum.forum_lastpost_user}>
In include/functions.php (anywhere is fine for these):
le="color: #000000"><?php function newbb_getTopicNameFromId( $topic_id ) { global $xoopsDB; $query = "select topic_title FROM " . $xoopsDB -> prefix('bb_topics') . " WHERE topic_id = " . $topic_id . ""; $result = $xoopsDB -> query($query); while (list($title) = $xoopsDB -> fetchRow($result)) { $topic_name = $title; } return $topic_name; } function newbb_getNewestThread($forum_id){ $array = array(); global $xoopsDB; $query = "select topic_title,topic_id,topic_poster FROM " . $xoopsDB -> prefix('bb_topics') . " WHERE forum_id = " . $forum_id . " ORDER BY topic_id DESC LIMIT 1"; $result = $xoopsDB -> query($query); foreach(mysql_fetch_assoc($result) as $key => $value) { $array[$key] = $value; } return $array; }
In forum.php (this goes in the function &display(&$forums_obj) at the bottom of the file, I added mine right above the line "$_forum_data['forum_lastpost_time'] = newbb_formatTimestamp($post_obj->getVar('post_time'));"):
le="color: #000000"><?php $_forum_data['forum_lastpost_id'] = $post_obj->getVar("topic_id"); $_forum_data['forum_lastpost_thread'] = newbb_getTopicNameFromId($post_obj->getVar("topic_id")); $_forum_data['forum_lastpost_thread_id'] = $forum_obj->getVar("forum_last_post_id"); $_newest_thread = newbb_getNewestThread($_forum_data["forum_id"]); $_forum_data['forum_newest_thread'] = $_newest_thread["topic_title"]; $_forum_data['forum_newest_thread_id'] = $_newest_thread["topic_id"]; $_forum_data['forum_newest_thread_creator'] = $users_linked[$_newest_thread["topic_poster"]];