How to display the latest forum postings on a website
This can be done independently from the forum script and database by parsing the RSS Feed of the forum. For this purpose you can use an RSS parser like SimplePie or Magpie RSS.
Example using SimplePie
<?php
// include SimplePie:
require_once('simplepie.inc');
// define the URL of the RSS Feed here:
$feed = new SimplePie('http://mylittleforum.net/forum/index.php?mode=rss&items=thread_starts');
// This makes sure that the content is sent to the browser as text/html and the UTF-8 character set (since we didn't change it).
$feed->handle_content_type();
?><h1>Latest topics on <a href="<?php echo $feed->get_permalink(); ?>"><?php echo $feed->get_title(); ?></a></h1><?php
// This displays at the most 10 items of the feed. To display all items you can
// just do it with foreach ($feed->get_items() as $item).
$max = $feed->get_item_quantity(10);
?><ul><?php
for($x = 0; $x < $max; $x++)
{
$item = $feed->get_item($x);
?><li><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a><br />
<small><?php $author = $item->get_author(); echo $author->get_name(); ?>, <?php echo $item->get_date('Y-m-d, H:i');
if($category = $item->get_category())
{
?> (<?php echo $category->get_label(); ?>)<?php
}
?></small></li><?php
}
?></ul>
Example using MagpieRSS
<?php
// path to the MagpieRSS parser:
require('magpierss/rss_fetch.inc');
// page charset:
// define("MAGPIE_OUTPUT_ENCODING", "UTF-8");
// RSS Feed:
$rss = fetch_rss('http://mylittleforum.mylittlehomepage.net/forum/index.php?mode=rss&items=thread_starts');
// if you want to display all postings use this line instead:
// $rss = fetch_rss('http://mylittleforum.mylittlehomepage.net/forum/index.php?mode=rss');
// How many postings should be displayed?
$maximum_items = 20;
?><h1>Latest topics</h1>
<ul><?php
$i=0;
foreach ($rss->items as $item )
{
?><li><a href="<?php echo $item['link']; ?>"><?php echo $item['title']; ?></a></li><?php
$i++;
if($i>=$maximum_items) break;
}
?></ul>