Hello
I want to show the thread count in a mainforum (in mainforum forumdisplay page). I mean how many threads are there in a mainforum?
This count must be the total count of all childforums of particular mainforum.
For example:
There are X threads in "Customization" mainforum (http://community.mybboard.net/forumdisplay.php?fid=8).
How can I do that?
Thank you.
Any coder help me on this please?
I have reached some sort of code.. but i'm afraid i mixed up. Do you mean like in
here let's call it place (1) or like in
this place let's call it place (2).
Let me explain with an example:
For example:
Total thread count in "Customization" mainforum = Thread Count In "Code Modifications" childforum + Thread Count In "Templates, Theme Sets and Graphics" childforum
Okay then you want to display it in the customization forum.
Open
forumdisplay.php
find
$forums = $child_forums['forum_list'];
below it add
$count = "";
$query = $db->query("SELECT DISTINCT fid FROM ".TABLE_PREFIX."forums WHERE parentlist LIKE '%,$fid,%' OR parentlist LIKE '$fid,%' GROUP BY fid");
while($fids = $db->fetch_array($query))
{
$count += $db->num_rows($db->query("SELECT tid FROM ".TABLE_PREFIX."threads WHERE fid='".$fids['fid']."'"));
}
Now in
forumdisplay_subforums put
There are {$count} threads in this parent.
Thank you so much. Wonderful code.
But we missed something:
It counts the hidden childforums' threads too.
How can we do that it doesn't count hidden childforums' threads if the user hasn't permission to view them?
this should work
$count = "";
$query = $db->query("SELECT DISTINCT fid FROM ".TABLE_PREFIX."forums WHERE parentlist LIKE '%,$fid,%' OR parentlist LIKE '$fid,%' GROUP BY fid");
while($fids = $db->fetch_array($query))
{
$fids_permissions = $forumpermissions[$fids['fid']];
if($fids_permissions['canview'] == "yes")
{
$count += $db->num_rows($db->query("SELECT tid FROM ".TABLE_PREFIX."threads WHERE fid='".$fids['fid']."'"));
}
else if(!$fids_permissions['canview'])
{
$query3 = $db->query("SELECT parentlist FROM ".TABLE_PREFIX."forums WHERE fid='".$fids['fid']."'");
$fetch_check = $db->fetch_array($query3);
$check = explode(",",$fetch_check['parentlist']);
for($i=0;$i<count($check);$i++)
{
$fids_permissions = $forumpermissions[$check[$i]];
if($fids_permissions['canview'] == "no")
{
$found = 1;
}
}
if($found != 1)
{
$count += $db->num_rows($db->query("SELECT tid FROM ".TABLE_PREFIX."threads WHERE fid='".$fids['fid']."'"));
}
}
}