Page 1 of 1

Last X topics from your phpBB...

Posted: Sat Mar 16, 2002 12:47 am
by z00om
I know probably 99.9% of you either have this or can make one if you want, but heres a simple "last X topics" listing for your phpBB. I don't know if its any different, but I built it off a phpBB2 RC-1... Some mods may be needed for adaptation. Here you go:

Code: Select all

<?php 
/* gets last X topics from your phpBB */ 
/* settings... */ 
/* setup your mysql conn... */ 
mysql_connect("host","user","pass"); 
/* enter your DB */ 
mysql_select_db("database"); 
/* how many to display? */ 
	/* to display ALL, go and remove " LIMIT $display" from $get_q. */ 
$display = 5; 
/* character cut-off */ 
	/* (set to 0 for NO cut off) */ 
$cutoff = 20; 
/* if cutoff is used, what should be displayed after? */ 
	/* hint: usually "..." or something. */ 
$cutoffending = "..."; 
/* URL to your forum (DIRECTORY ONLY!) */ 
	/* ie: /phpBB2 */ 
	/* _NO_ trailing slash! */ 
$url = "/forums"; 
/* --- end settings! --- */ 


$get_q = "SELECT topic_id,topic_title FROM topics ORDER BY topic_id DESC LIMIT $display"; 
$get_r = mysql_query($get_q); 
while ($topic = mysql_fetch_row($get_r)) { 
	if ($cutoff != 0) { 
		if(strlen($topic[1]) > $cutoff) { 
			$link = substr($topic[1], 0, $cutoff) . $cutoffending; 
		} else { 
			$link = $topic[1]; 
		} 
	} else { 
		$link = $topic[1]; 
	} 
echo ". <a href=$url/viewtopic.php?t=$topic[0]>$link</a><br>\n"; 
} 
/* end... */ 
/* CREDIT: Scott Roberts - http://z00om.com */ 
?>
Hope it's good for something :)

Posted: Sat Mar 16, 2002 1:06 am
by Bear
I'm sure the folks over at mods.phpbb.com would like a post over there.

Posted: Sat Mar 16, 2002 11:03 pm
by Matthijs
I know (since I did one myself) there are already a few posts there of a MOD doing this, and better (this one will display titles of topics in hidden forums).

Posted: Sun Mar 17, 2002 12:14 am
by dougk_ff7
Although the developers appreciate the contribution of code, this is a mod, and it needs to be posted to http://mods.phpbb.com/. As for this topic, it's locked.
Sorry!