Page 1 of 1

Latest Topics from Specific Forum Block

Posted: 13. February 2009 01:45
by bjankord
I dont know if this can be done already but I'd like a block that displays only the recent topic titles from certain forums.
The Recent block that comes with board3 kinda does what Im looking for, yet it pulls other topics in too.

I found a mod that does something similar to what Im looking for, yet it seems to show replys to the topic to when it pulls it into the block.
Mod: viewtopic.php?f=9&t=1227

I need something that will just display the recent topic titles from a forum I choose and have the topic titles link to the topic.

I would like to have 3 blocks, display 3 seperate recent topics in certain forums, yet if someone can make one that works, I can probably figure out how to duplicate it for the other forums I want to show recent topics from.

Any help or direction would be greatly appreciated!!

Re: Latest Topics from Specific Forum Block

Posted: 13. February 2009 03:37
by bjankord
I found a code that does what I'm looking for.

The Code:
<?

// change to the path to your forum
$path = './phpBB3/';

// amount of topics to show
$amount = 5;

// forum ids to NOT show topics forum, separated by commas
$exclude = '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,32';


// ------ no need to edit below ------ //

require_once("{$path}config.php");

$conid = mysql_connect($dbhost, $dbuser, $dbpasswd);
$db = mysql_select_db($dbname, $conid);

unset($dbpasswd);

$sql_where = 'WHERE `forum_id` > -1 ';

if($exclude != '')
{
$exclude_forums = explode(',', $exclude);
foreach ($exclude_forums as $id)
{
if ($id > 0)
{
$sql_where .= ' AND `forum_id` <> ' . trim($id);
}
}
}

$sql = "SELECT `topic_id`, `topic_title` FROM `{$table_prefix}topics` {$sql_where} ORDER BY `topic_time`DESC LIMIT 0, {$amount}";
$result = mysql_query($sql, $conid);

$topics_html = '';
while($topic = mysql_fetch_array($result))
{
$topics_html .= "<a href=\"{$path}viewtopic.php?t={$topic['topic_id']}\">{$topic['topic_title']}</a><br />";
}
mysql_close($conid);

echo $topics_html;
?>


The only thing I would like to change is instead of listing the forums you wish to exclude,

example:

// forum ids to NOT show topics forum, separated by commas
$exclude = '1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,32';

You would choose the forums you wish to include.

Any help on this would be greatly appreciated!!

Re: Latest Topics from Specific Forum Block

Posted: 10. August 2009 12:06
by Kevin
I just made a guide on adding a second news block:
Second news block / zweiter News Block