There is no message.
===== URL schemes =====
PunBB 1.3 natively supports URL rewriting, including SEF URLs.
How to enable URL rewriting:\\
- Rename file ''.htaccess.dist'' in the root of your forum to ''.htaccess''.
- Go to Administration => Settings (''/admin/settings.php?section=setup''), find ''URL Scheme'' section there.
- Choose the URL scheme you like and save changes.
===== Database helpers =====
On ''include/common.php'' inclusion, the proper implementation of [[database layer]] class is being also included according to forum configuration.
An instance of this database layer named ''$forum_db'' is being created in global scope to provide [[database helpers]].
==== How to perform a query ====
* Direct query. You can simply write an SQL-statement and execute it.
$result = $forum_db->query('SELECT * FROM topics WHERE id = 10');
Be sure, that your SQL code is cross-compatible with all database engines supported by PunBB.
* Using [[query builder]]. You may transparently build database queries. All the specific of database engines and database structure will automatically be taken in account. Example of usage (FIXME make it more informative):
$query = array(
'SELECT' => '*',
'FROM' => 'topics',
'WHERE' => 'id = 10'
);
$result = $forum_db->query_build($query);
See [[query builder]] page for details.
==== How to work with query results ====
For example, we have this query:
$query = array(
'SELECT' => 't.id, t.poster, t.subject, t.posted',
'FROM' => 'topics AS t',
'WHERE' => 't.forum_id = 1'
);
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
* To know how many rows this query returns, use this:
$forum_db->num_rows($result);
* To fetch the current row to associative array:
$data = $forum_db->fetch_assoc($result);
//An example of getting topic_id
$topic_id = $data['id'];
* To fetch the current row to numeric array:
$data = $forum_db->fetch_row($result);
//An example of getting topic_id
$topic_id = $data[0];
* To fetch only some values from the current row:
//This code will fetch only the topic id and the topic subject
list($id,, $subject,) = $forum_db->fetch_row($result);
* To process all rows in a set you can use this code:
while ($cur_row = $forum_db->fetch_assoc($result))
{
//Actions with $cur_row
}
===== Template customization =====
==== How to include my file into *.tpl? ====
Use the ''forum_include "file.ext"'' substitute to include the file ''
===== Common tasks =====
==== Recent 10 posts ====
'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))
{
?>
', $cur_post['subject'], '';
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 '
', "\n", $cur_post['message'];
}
echo '';
}
?>
==== Showing all topics ====
't.id, subject, t.last_post, forum_id',
'FROM' => 'topics AS t',
'JOINS' => array(
array(
'INNER JOIN' => 'forums AS f',
'ON' => 'f.id = t.forum_id'
)
),
'ORDER BY' => 'last_post DESC',
);
$result = $forum_db->query_build($query) or error(__FILE__, __LINE__);
if (!$forum_user['is_guest'])
$tracked_topics = get_tracked_topics();
?>
fetch_assoc($result))
{
echo '- ';
if (!$forum_user['is_guest'] && $cur_topic['last_post'] > $forum_user['last_visit']
&& (!isset($tracked_topics['topics'][$cur_topic['id']]) || $tracked_topics['topics'][$cur_topic['id']] < $cur_topic['last_post'])
&& (!isset($tracked_topics['forums'][ $cur_topic['forum_id'] ]) || $tracked_topics['forums'][ $cur_topic['forum_id'] ] < $cur_topic['last_post']))
echo '[unread] ';
else
echo '[read] ';
echo '', $cur_topic['subject'], '';
echo '
';
}
?>
==== Showing active topics ====
't.id AS tid, t.poster, t.subject, t.posted AS has_posted, t.last_post, t.last_post_id, t.num_replies, t.num_views, t.closed, t.sticky,
t.forum_id, t.last_poster',
'FROM' => 'topics AS t',
'JOINS' => array(
array(
'INNER JOIN' => 'forums AS f',
'ON' => 'f.id=t.forum_id'
),
array(
'LEFT JOIN' => 'forum_perms AS fp',
'ON' => '(fp.forum_id=f.id AND fp.group_id='.$forum_user['g_id'].')'
)
),
'ORDER BY' => 't.last_post DESC',
'LIMIT' => $topics_count
);
$result_active = $forum_db->query_build($query_active_topics) or error(__FILE__, __LINE__);
if ($forum_db->num_rows($result_active) == 0) {
?>
fetch_assoc($result_active))
{
// Start from scratch
$item_subject = $item_body = $item_status = $item_nav = $item_title = array();
$item_indicator = '';
if (!$forum_user['is_guest'] && $forum_config['o_show_dot'] == '1' && $cur_set['has_posted'] > 0)
{
$item_title['posted'] = ''.$lang_forum['You posted indicator'].'';
$item_status['posted'] = 'posted';
}
$item_title['link'] = ''.forum_htmlencode($cur_set['subject']).'';
if (!empty($item_nav))
$item_title['nav'] = ''.sprintf($lang_forum['Topic navigation'], implode(' ', $item_nav)).'';
$item_body['subject']['title'] = ''.forum_number_format(++$item_num).' '.implode(' ', $item_title).'
by '.forum_htmlencode($cur_set['poster']).'';
if ($cur_set['sticky'] == '1')
{
$item_subject_status['sticky'] = $lang_forum['Sticky'];
$item_status['sticky'] = 'sticky';
}
if ($cur_set['closed'] != '0')
{
$item_subject_status['closed'] = $lang_forum['Closed'];
$item_status['closed'] = 'closed';
}
// Does this topic contain posts we haven't read? If so, tag it accordingly.
if (!$forum_user['is_guest'] && $cur_set['last_post'] > $forum_user['last_visit'] && (!isset($tracked_topics['topics'][$cur_set['tid']]) || $tracked_topics['topics'][$cur_set['tid']] < $cur_set['last_post']) && (!isset($tracked_topics['forums'][$cur_set['forum_id']]) || $tracked_topics['forums'][$cur_set['forum_id']] < $cur_set['last_post']))
{
$item_status['new'] = 'new';
}
if (!empty($item_subject_status))
$item_subject['status'] = ''.sprintf($lang_forum['Item status'], implode(' ', $item_subject_status)).'';
$item_body['subject']['desc'] = implode(' ', $item_subject);
if (empty($item_status))
$item_status['normal'] = 'normal';
$item_style = (($item_num % 2 != 0) ? ' odd' : ' even').(($item_num == 1) ? ' main-first-item' : '').((!empty($item_status)) ? ' '.implode(' ', $item_status) : '');
$item_body['info']['replies'] = ''.forum_number_format($cur_set['num_replies']).' '.(($cur_set['num_replies'] == 1) ? $lang_forum['Reply'] : $lang_forum['Replies']).' ';
$item_body['info']['views'] = ''.forum_number_format($cur_set['num_views']).' '.(($cur_set['num_views'] == 1) ? $lang_forum['View'] : $lang_forum['Views']).' ';
$item_body['info']['last_post'] = ''.$lang_index['Last post'].' '.format_time($cur_set['last_post']).' '.sprintf($lang_index['Last poster'], forum_htmlencode($cur_set['last_poster'])).' ';
?>
==== Login form outside the forum ====
'',
'redirect_url' => '',
'csrf_token' => ''
);
?>