Latest Topics from Specific Forum Block

Post Reply

Topic author
bjankord
Active Member
Posts: 3
Joined: 12. February 2009 05:02

Latest Topics from Specific Forum Block

Post 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!!

Topic author
bjankord
Active Member
Posts: 3
Joined: 12. February 2009 05:02

Re: Latest Topics from Specific Forum Block

Post 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!!
User avatar

Kevin
Site Admin
Posts: 2989
Joined: 7. January 2006 20:11
phpBB.de User: Saint
phpBB.com User: Saint_hh
Location: Hamburg
Contact:

Re: Latest Topics from Specific Forum Block

Post by Kevin »

I just made a guide on adding a second news block:
Second news block / zweiter News Block
~~~ They say the definition of madness is doing the same thing and expecting a different result ~~~

Kein Support per PN / No support via PM!
Post Reply

Return to “Modification Requests”