10-26-2000, 10:18 PM
This optimization just may help you out more than the forumdisplay did! Check it out...
edit global.php (the one in /forum, not the admin one)
find:
// ###################### Start makeforumjump #######################
Delete everything between that line and this line:
// ###################### Start countchar #######################
In it's place put this:
function makeforumjump()
{
// this generates the jump to box
global $DB_site,$forumid,$optionselected,$usecategories, $jumpforumid,$jumpforumtitle, $jumpforumbits,$curforumid;
global $hideprivateforums,$defaultselected, $forumjump,$bbuserid,$bbusergroupid;
if ($forumid!="")
{
$curforumid=$forumid;
}
else
{
if ($threadid!="")
{
$getforumid=$DB_site->query_first("SELECT forumid FROM thread WHERE threadid=$threadid");
$curforumid=$getforumid[forumid];
}
}
$forums=$DB_site->query("SELECT category.categoryid, category.title AS categorytitle,
forumid, forum.title AS forumtitle
FROM category
LEFT JOIN forum ON (category.categoryid = forum.categoryid)
WHERE category.displayorder<>0 AND forum.displayorder <> 0 AND active=1
ORDER BY category.displayorder, forum.displayorder");
$firstcat = 0;
while ($forum=$DB_site->fetch_array($forums))
{
$currentcat = $forum[categoryid];
if ($usecategories == 1)
{
$optionselected="";
if ($firstcat != $currentcat) // Print Category
{
$firstcat = $forum[categoryid];
// This creates our "blank line" in the dropdown
$jumpforumid="";
$jumpforumtitle="";
eval("\$jumpforumbits .= \"".gettemplate("jumpforumbit")."\";");
$jumpforumid="cat$forum[categoryid]";
$jumpforumtitle="Category: $forum[categorytitle]";
eval("\$jumpforumbits .= \"".gettemplate("jumpforumbit")."\";");
$jumpforumid="";
$jumpforumtitle="--------------------";
eval("\$jumpforumbits .= \"".gettemplate("jumpforumbit")."\";");
}
}
if ($hideprivateforums==1)
{
$getperms=getpermissions($bbuserid,$bbusergroupid, $forum[forumid]);
}
else
{
$getperms[canview]=1;
}
if ($getperms[canview]==1)
{
$jumpforumid=$forum[forumid];
$jumpforumtitle=" $forum[forumtitle]";
if ($curforumid==$jumpforumid)
{
$optionselected="selected";
$selectedone=1;
}
eval("\$jumpforumbits .= \"".gettemplate("jumpforumbit")."\";");
}
}
if ($selectedone!=1)
{
$defaultselected="selected";
}
eval("\$forumjump = \"".gettemplate("forumjump")."\";");
}
For the record the current forumjump retrieves a list of categories. Then for each record in that result set it runs a query of the forums that belong to that category. Have 50 categories, you have 51 queries. Now you would have 2. We still need to do something about that "getperms" function as it will run a query each time per forum. How about we retrieve that information along with the bbusername, bbpassword, bbuserid and have it available instead of constantly retrieveing it all the time. Just a thought.
[Edited by Ed Sullivan on 10-27-2000 at 05:45 PM]
edit global.php (the one in /forum, not the admin one)
find:
// ###################### Start makeforumjump #######################
Delete everything between that line and this line:
// ###################### Start countchar #######################
In it's place put this:
function makeforumjump()
{
// this generates the jump to box
global $DB_site,$forumid,$optionselected,$usecategories, $jumpforumid,$jumpforumtitle, $jumpforumbits,$curforumid;
global $hideprivateforums,$defaultselected, $forumjump,$bbuserid,$bbusergroupid;
if ($forumid!="")
{
$curforumid=$forumid;
}
else
{
if ($threadid!="")
{
$getforumid=$DB_site->query_first("SELECT forumid FROM thread WHERE threadid=$threadid");
$curforumid=$getforumid[forumid];
}
}
$forums=$DB_site->query("SELECT category.categoryid, category.title AS categorytitle,
forumid, forum.title AS forumtitle
FROM category
LEFT JOIN forum ON (category.categoryid = forum.categoryid)
WHERE category.displayorder<>0 AND forum.displayorder <> 0 AND active=1
ORDER BY category.displayorder, forum.displayorder");
$firstcat = 0;
while ($forum=$DB_site->fetch_array($forums))
{
$currentcat = $forum[categoryid];
if ($usecategories == 1)
{
$optionselected="";
if ($firstcat != $currentcat) // Print Category
{
$firstcat = $forum[categoryid];
// This creates our "blank line" in the dropdown
$jumpforumid="";
$jumpforumtitle="";
eval("\$jumpforumbits .= \"".gettemplate("jumpforumbit")."\";");
$jumpforumid="cat$forum[categoryid]";
$jumpforumtitle="Category: $forum[categorytitle]";
eval("\$jumpforumbits .= \"".gettemplate("jumpforumbit")."\";");
$jumpforumid="";
$jumpforumtitle="--------------------";
eval("\$jumpforumbits .= \"".gettemplate("jumpforumbit")."\";");
}
}
if ($hideprivateforums==1)
{
$getperms=getpermissions($bbuserid,$bbusergroupid, $forum[forumid]);
}
else
{
$getperms[canview]=1;
}
if ($getperms[canview]==1)
{
$jumpforumid=$forum[forumid];
$jumpforumtitle=" $forum[forumtitle]";
if ($curforumid==$jumpforumid)
{
$optionselected="selected";
$selectedone=1;
}
eval("\$jumpforumbits .= \"".gettemplate("jumpforumbit")."\";");
}
}
if ($selectedone!=1)
{
$defaultselected="selected";
}
eval("\$forumjump = \"".gettemplate("forumjump")."\";");
}
For the record the current forumjump retrieves a list of categories. Then for each record in that result set it runs a query of the forums that belong to that category. Have 50 categories, you have 51 queries. Now you would have 2. We still need to do something about that "getperms" function as it will run a query each time per forum. How about we retrieve that information along with the bbusername, bbpassword, bbuserid and have it available instead of constantly retrieveing it all the time. Just a thought.
[Edited by Ed Sullivan on 10-27-2000 at 05:45 PM]