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]
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
I installed this hack and am wandering around trying to figure out where this is called from. On what screens should I notice this happening? On the main screen when the forums and categories are loaded?
Just curious, and thanks for the extra effort, rangersfan!
Originally posted by wluke Your three optimizations are great. I was just wondering if you know if they are to be included in 1.1.4 and 2.0 or did John redo the coding.
Knowing this will greatly help development along at SitePoint.
The 1.1.4 stable release is planned to have about a dozen known bug fixes along with many new optimizations, including those posted by rangersfan and Stallion, along with a few others.
Of course I am sure they will all make in into 2.0 as well.