1
CBung
Latest Post / Newest Thread (newbb)
  • 2009/3/6 5:17

  • CBung

  • Just popping in

  • Posts: 14

  • Since: 2009/3/4 5


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):

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):

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'));"):

$_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"]];

2
Anonymous
Re: Latest Post / Newest Thread (newbb)
  • 2009/3/6 8:40

  • Anonymous

  • Posts: 0

  • Since:


Many thanks for sharing

Do you have link to a site where we can see the effect of your changes?

Thread moved to this section as it was originally posted in "Core Hacks"

Login

Who's Online

227 user(s) are online (160 user(s) are browsing Support Forums)


Members: 0


Guests: 227


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits