Show category
From PunBB Resource Wiki
Contributed by El Bekko
[edit]
What it does
This page explains how to modify your index.php to show only on category on request.
[edit]
How to use it
Well, it's really simple. If you want all categories to show, just use the link http://www.example.com/forum/index.php. Else, use this type of link: http://www.example.com/forum/index.php?cid=<number>, where <number> is the category id.
[edit]
What to change
- Open index.php
- Find ~line 41
- Replace
// Print the categories and forums $result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE fp.read_forum IS NULL OR fp.read_forum=1 ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
- With
// Print the categories and forums $cid_sql = isset($_GET['cid']) ? "c.id=".intval($_GET['cid']) . " AND" : ''; $result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE '.$cid_sql.' fp.read_forum IS NULL OR fp.read_forum=1 ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
- Then create link to category name by replacing (~line 60):
<div id="idx<?php echo $cat_count ?>" class="blocktable"> <h2><span><?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></span></h2>
- With
<div id="idx<?php echo $cat_count ?>" class="blocktable"> <h2><span><a href="http://YourSite.com/YourForumPath/index.php?cid=<?php echo $cur_category = $cur_forum['cid']; ?>"><?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></a></span></h2>
- Where http://YourSite.com/YourForumPath/index.php is path to your forum index page.

