PDA

View Full Version : Sub-Forums


valid
09-19-2001, 08:15 PM
Where can I get this hack?

Link?

Screenshop attached!

ethank
09-19-2001, 08:36 PM
Originally posted by valid
Where can I get this hack?

Link?

Screenshop attached!

Its just a code mod. I'll post the code tonight. Its quite simple really and probably not the best way to do it.

EThan

ethank
09-19-2001, 08:38 PM
Anyhow:

Before this in index.php:


if ((!$forumperms['canpostnew'] and $showlocks) or $forum['allowposting']==0) {
$forum['onoff'].='lock';
}


Add this:


// ADDED BY ERK
if ($forum[cancontainthreads]!=0)
{

$subforums=$DB_site->query("select title,forumid from forum where parentid = $forum[forumid] and active != 0");
if ($DB_site->num_rows($subforums)>0)
{
$forum['description'] .= "<BR><B>Sub-forums:</B> ";
}
$i = 0;
while ($forum_child=$DB_site->fetch_array($subforums))
{
$i++;
$permission=$DB_site->query_first("select accessmask from access where userid = $bbuserinfo[userid] AND forumid = $forum_child[forumid]");
if ($permission['acessmask'] != 0 || $permission['accessmask'] == null)
{
$subs.="<a href=\"forumdisplay.php?forumid=$forum_child[forumid]&s=$session[sessionhash]\">$forum_child[title]</a>";
if ($i < $DB_site->num_rows($subforums))
{
$subs.=", ";
}
}
}
$DB_site->free_result($subforums);
$forum_child=null;
$forum['description'].= $subs;
$subs=null;
}
// END ADDED


And in forumdisplay.php, do the same thing.

Ethan

chrispadfield
09-19-2001, 10:37 PM
As the description tag allows html you could just type in the html. depends how often you change your forums i guess.

ethank
09-19-2001, 10:45 PM
Originally posted by chrispadfield
As the description tag allows html you could just type in the html. depends how often you change your forums i guess.

Yeah, but this code takes permissions into account, and with my site some forums have varying access masks for certain users, so.....

Ethan

valid
09-20-2001, 12:49 AM
Thank you, nice hack! : P

valid
09-20-2001, 01:13 AM
Little fix, this displays the Sub-Forums in order they are added!


// ADDED BY ERK
if ($forum[cancontainthreads]!=0)
{

$subforums=$DB_site->query("select title,forumid from forum where parentid = $forum[forumid] and active != 0 ORDER BY parentid,displayorder");
if ($DB_site->num_rows($subforums)>0)
{
$forum['description'] .= "<BR><BR><B>Sub-Forums:</B> ";
}
$i = 0;
while ($forum_child=$DB_site->fetch_array($subforums))
{
$i++;
$permission=$DB_site->query_first("select accessmask from access where userid = $bbuserinfo[userid] AND forumid = $forum_child[forumid]");
if ($permission['acessmask'] != 0 || $permission['accessmask'] == null)
{
$subs.="<a href=\"forumdisplay.php?forumid=$forum_child[forumid]&s=$session[sessionhash]\">$forum_child[title]</a>";
if ($i < $DB_site->num_rows($subforums))
{
$subs.=", ";
}
}
}
$DB_site->free_result($subforums);
$forum_child=null;
$forum['description'].= $subs;
$subs=null;
}
// END ADDED