Topic: News Page
Well, i've been extremely bored lately and decided to code a little something
What this code does is form a punbb page that retrieves "news" from a specific forum of your choice. You are also capable of setting a maximum amount of news to retrieve from the database. It's nothing special, but i hope that some of you will put this code to good use
<?php
define('PUN_ROOT', './');
define('PUN_QUIET_VISIT', 1);
require PUN_ROOT.'include/common.php';
// Set the page title here
$page_title = pun_htmlspecialchars($pun_config['o_board_title']) . ' / Home';
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';
require PUN_ROOT.'include/parser.php';
// Load the forums.php language file
require PUN_ROOT.'lang/'.$pun_user['language'].'/index.php';
// News Information
$news = '3';
$forum = '1';
// Retrieve News From Database
$db_news = $db->query('SELECT t.id, t.subject, t.num_replies, t.num_views, t.forum_id, p.topic_id, p.poster, p.poster_id, p.message, p.hide_smilies, p.posted FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'posts AS p ON t.id=p.topic_id AND p.posted=t.posted INNER JOIN '.$db->prefix.'users AS u ON u.id=p.poster_id INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id WHERE t.forum_id='.$forum.' AND t.moved_to IS NULL AND f.redirect_url IS NULL ORDER BY t.posted DESC LIMIT '.$news) or error('Unable to fetch the portal news', __FILE__, __LINE__, $db->error());
if ($db->num_rows($db_news))
{
while($news = $db->fetch_assoc($db_news))
{
// Set Some Variables
$message = parse_message($news['message'], $news['hide_smilies']);
$subject = $news['subject'];
$poster = '<a href="profile.php?id='.$news['poster_id'].'">'.$news['poster'].'</a>';
$date_posted = format_time($news['posted']);
$replies = $news['num_replies'];
$views = $news['num_views'];
$news_id = $news['id'];
// Output News
echo "\t\t\t\t".'<div class="blocktable" style="margin-bottom: 10px"><h2><span>'.$subject.'</span></h2><div class="box"><div class="inbox"><table cellspacing="0"><thead><tr><th class="tcl">'.$date_posted.' » by '.$poster.'</th></tr></thead><tbody><tr><td class="tcl"><div style="padding: 5px 2px 7px 5px">'.$message.'</div></td></tr></tbody><thead><tr><th class="tcl">Replies: '.$replies.' » Views: '.$views.' » <a href="post.php?tid='.$news_id.'">Post Reply</a></th></tr></thead></table></div></div></div>'."\n";
}
}
// Require the footer
require PUN_ROOT.'footer.php';
Don't forget that you are able to configure the news information via these two lines:
// News Information
$news = '3';
$forum = '1';
A demo of this paticular page can be found here.