PDA

View Full Version : [RELEASE] forumjump Optimization


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]

10-26-2000, 10:21 PM
cool.. the forumdisplay one really helped me out ALOT ... by any chance you know if any of the hacks would of changed it ?

10-26-2000, 10:21 PM
I don't think any hacks would have changed this.

Also don't get upset at me not releasing the calendar hack if I'm spending time optimizing queries :)

[Edited by rangersfan on 10-26-2000 at 07:26 PM]

10-26-2000, 10:34 PM
Rangersfan well done! :)

10-26-2000, 10:42 PM
:( i added it on my test forum i got an error


Parse error: parse error, expecting `','' or `';'' in /path/to/global.php on line 550

Fatal error: Call to a member function on a non-object in /path/to/global.php on line 349

10-26-2000, 10:47 PM
You know what? If I edit the post it is fine, but if you look where it says

curfor umid;

The forum has inserted a space from the damned wordwrap bug.

You can dl it here ->

http://www.hedgehogwheels.com/hacks/forumjump_optimization.txt

10-26-2000, 11:02 PM
Wow this sounds great. I added it to my forums.

I look forward to more optimizations...if it keeps up maybe I won't need to buy Sybase or another databae solution.

Thanks rangersfan. Do you have any other optimizations in mind or planned?

10-26-2000, 11:03 PM
thanks i downloaded the txt one you posted and it works great on my test and live vBs :D

10-26-2000, 11:19 PM
Another one? :)

Cramed for time right now, but is this one similar to:
http://www.vbulletin.com/forum/showthread.php?threadid=2985

Or does it improve a different area. I'm assuming its different, since you had posted in the other thread before, but don't have the time to run through the code atm.

Keep 'em coming!

10-26-2000, 11:28 PM
Oh it achieves the same but mine makes a hell of a lot more sense. I posted alot of questions about errors and such with his hack and he never responded.

In reality, someone on vbulletin.org asked for an optimization of forumjump and I had forgot fodder had made one.

[Edited by rangersfan on 10-26-2000 at 08:30 PM]

10-26-2000, 11:32 PM
hehe i really love you sig rangersfan ;)

10-26-2000, 11:35 PM
yeah I think that my sig with the links will not be needed anymore. :)

10-27-2000, 11:41 AM
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!

10-27-2000, 01:28 PM
It is the small pulldown menu that appears on forumdisplay and allows you to select a forum to "jump to".

10-27-2000, 02:53 PM
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.

10-27-2000, 02:57 PM
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.

I think its in 2.0

10-27-2000, 02:59 PM
I have no clue, I have never had any communication with anybody at Jelsoft.

10-27-2000, 03:03 PM
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.

-Chris

10-27-2000, 03:19 PM
(blatant reply to bump my posts to 1000 )

10-27-2000, 05:15 PM
For the record, I am copying rangersfan with his sig idea, and its not the other way around. :-)

10-27-2000, 08:44 PM
Originally posted by rangersfan
The forum has inserted a space from the damned wordwrap bug.Actually, ironically, that's not the bug. Put spaces between your commas and you'll find it's fine. [I'll go do that real quick] FYI, John fixed the bug. 1.1.4 will have the fix.

Also, when I get around to it, I think I'll swipe rangersfan's sig too :) It makes sense, and gets rid of a lot of those "[request] WHERE IS IT?" threads.

10-27-2000, 09:14 PM
Originally posted by Stallion
For the record, I am copying rangersfan with his sig idea, and its not the other way around. :-) who's copying who's sig :p

10-27-2000, 10:04 PM
I had to remove the hack links to give more space to add all my new links soon.

Copying sigs hey??? :)

11-01-2000, 03:24 AM
When using the code from forumjump_optimization.txt I get the following error:

Parse error: parse error, expecting `T_VARIABLE' or `'$'' in global.php on line 740

Any ideas?

11-01-2000, 03:29 AM
Cold Steel that means you missed putting a $ on a variable. V1.1.4 has this optimization in it so why don't you just install it?

11-01-2000, 03:52 AM
Thanks Freddie, I hadn't even noticed that 1.1.4 was out!

I think I'm going to wait for 2.0 before working on anything else.

BTW great site - my woman wanted to get a hedgehog for a looong time, and she really enjoyed looking at the photos on your site. :)

11-01-2000, 03:59 AM
Thanks :)