This is an old revision of the document!
Table of Contents
PunBB 1.3 integration
General
Common tasks
Recent 10 posts
<?php define('RECENT_POSTS_SHOW_POST', true); // Set to false to show topic subject only define('RECENT_POSTS_MAX_POST_LENGTH', 20); // Limit length of the post text displayed if (!defined('FORUM_ROOT')) define('FORUM_ROOT', './'); require FORUM_ROOT.'include/common.php'; // Get 10 lastest posts $query = array( 'SELECT' => 'p.id, p.message, t.subject', 'FROM' => 'posts AS p', 'JOINS' => array( array( 'LEFT JOIN' => 'topics AS t', 'ON' => 'p.topic_id = t.id' ) ), 'ORDER BY' => 'p.posted DESC', 'LIMIT' => '0,10' ); $result = $forum_db->query_build($query) or error(__FILE__, __LINE__); $recent_posts = array(); while ($cur_post = $forum_db->fetch_assoc($result)) $recent_posts[] = $cur_post; // Print out posts if (!empty($recent_posts)) { ?> <ul> <?php foreach($recent_posts as $cur_post) { echo '<li><a href="', forum_link($forum_url['post'], $cur_post['id']), '">', $cur_post['subject'], '</a>'; if (RECENT_POSTS_SHOW_POST) { if (utf8_strlen($cur_post['message']) > RECENT_POSTS_MAX_POST_LENGTH) $cur_post['message'] = utf8_substr($cur_post['message'], 0, RECENT_POSTS_MAX_POST_LENGTH).'…'; echo '<br />', "\n", $cur_post['message']; } echo '</li>'; } ?> </ul> <?php } ?>