PDA

View Full Version : Addon: Auto-populate Navbar menu (for John's Arcade V3)


Natch
02-06-2004, 10:00 PM
Addon: Auto-populate Navbar menu (for John's Arcade V3)

What this hack does:

It replaces the link in your navbar for the Arcade with a Dropdown menu of all the games that are active in your Arcade.

Motivation: Extrapolated from my other auto-populating menu for Erwin's vB3 hack ...

Files to edit: 2
global.php
includes/functions.php
Template to edit: 1
navbar
New phrases to insert: 1
Queries added: 1

Step 1: Add the following in the Phrase Manager under GLOBAL

Alternate: you can import the single phrase using the included XML file

************************************************** ******
Name: arcade_addon_title
Phrase: The Arcade!
************************************************** ******

Step 2: Add the following at the bottom of global.php

Find:

/*================================================= =====================*\
|| ################################################## ##################
|| # Downloaded:


Add Before:

// Addon to John's vB3 ArcadeV3 hack - created by Natch
$nav_arcade = genArcadeMenu();
// Addon to John's vB3 ArcadeV3 hack - created by Natch


Step 3: Add the following at the bottom of includes/functions.php

Find:

/*================================================= =====================*\
|| ################################################## ##################
|| # Downloaded:


Add Before:

// Addon to John's vB3 ArcadeV3 hack - created by Natch
function genArcadeMenu() {
global $DB_site,$vboptions;
$theseGames = $DB_site->query("SELECT gameid,title,gamesettings FROM " . TABLE_PREFIX . "games ORDER BY title");
while ($thisGame = $DB_site->fetch_array($theseGames)) {
$arcmenu.= (is_int($thisGame[gamesettings]/2)) ? "" : "\t\t<tr><td class=\"vbmenu_option\"><a href=\"$vboptions[bburl]/arcade.php?$session[sessionurl]do=play&amp;gameid=".$thisGame[gameid]."\">".$thisGame[title]."</a></td></tr>\n";
}
return $arcmenu;
}
// Addon to John's vB3 ArcadeV3 hack - created by Natch


Step 4: Add the following to the template 'navbar'

Find:

<!-- / NAVBAR POPUP MENUS -->


Add Before:

<!-- Addon to John's vB3 ArcadeV3 hack - created by Natch -->
<if condition="$show['member']"> <!-- remove this line and the endif if you wish all users and guests to view the menu -->
<!-- flash arcade auto-menu -->
<div class="vbmenu_popup" id="flasharcade_menu" style="display:none">
<table cellpadding="4" cellspacing="1" border="0">
<tr><td class="thead"><a href="$vboptions[bburl]/arcade.php?$session[sessionurl]" title="$vbphrase[arcade_addon_title]">$vbphrase[arcade_addon_title]</a></td></tr>
$nav_arcade
</table>
</div>
<!-- / flash arcade auto-menu -->
</if>
<!-- Addon to John's vB3 ArcadeV3 hack - created by Natch -->


Find:

<td class="vbmenu_control"><a href="arcade.php?$session[sessionurl]">Arcade</a></td>


REPLACE WITH:

<!-- Addon to John's vB3 ArcadeV3 hack - created by Natch -->
<if condition="$show['member']"> <!-- remove this line and the endif if you wish all users and guests to view the menu -->
<td id="flasharcade" class="vbmenu_control"><a href="#flasharcade">$vbphrase[arcade_addon_title]</a> <script type="text/javascript"> vbmenu_register("flasharcade"); </script></td>
</if>
<!-- Addon to John's vB3 ArcadeV3 hack - created by Natch -->


NOTE: in the two navbar edits there are conditionals that WILL CAUSE the menu to only appear to Registered users - remove these conditional wrappers to show the menu to all and sundry ... ;)

Should work :) Enjoy, and props to John for his great Hack ...
U can see a demo @ http://www.mobileforces.org/ << running vBulletin 3.0.0 RC4 and vBIndex RC3, on PHP v4.3.4, MySQL 4.0.15

Screenshots attached: one with all default games enabled, and one with asteroids disabled

UPDATE: fixed up my comments - damn that copy and paste ... those that downloaded the attachment b4 5AM +11GMT, re-get the attachment, or make the following alterations to the above script:

Find twice:

// remove this line and the endif if you wish all users and guests to view the menu


Replace with:

<!-- remove this line and the endif if you wish all users and guests to view the menu -->


UPDATE: IF YOU WANT ONLY N MOST POPULAR GAMES - check out this post (https://vborg.vbsupport.ru/showpost.php?p=475024&postcount=17)

UPDATE: if you wat IMGAES in your dropdown menu, check out this post (https://vborg.vbsupport.ru/showpost.php?p=536117&postcount=43)

John
02-07-2004, 02:13 PM
Very nice, good work Natch!

msimplay
02-07-2004, 02:59 PM
what querie ?

Natch
02-07-2004, 03:20 PM
what querie ?
It performs one query to the games table to get game title (for the link wording), game id (for the link itself), and game settings (to check the game is enabled from the Arcade CP) ...

Blackbeard
02-07-2004, 03:25 PM
Great work m8

but when i click on arcade at top of list and it takes me to arcade page i see this above and below the nav bar

// remove this line and the endif if you wish all users and guests to view the menu

what have i done wrong??

Natch
02-07-2004, 03:55 PM
Okies - I get the bug :)

I'll fix this up now and get back to u ...

Natch
02-07-2004, 04:03 PM
UPDATED: above - check the new additions / modifications or simply remove the erroneous commenting as mentioned in post #5 (https://vborg.vbsupport.ru/showpost.php?p=474043&postcount=5)

13th_Disciple
02-07-2004, 04:33 PM
thank you Natch.. will add right now.. good work.. also gonna use the flash player navbar auto-populate..

Blackbeard
02-07-2004, 04:35 PM
Thanks, works great thanks for quick reply

M1th
02-07-2004, 04:36 PM
not a bad idea, but it creates a HUGE dropdown menu. Imagine having 100 games for the arcade... *grins* :D

Natch
02-07-2004, 04:39 PM
Good thing the drop-downs are persistent and you can scroll LOL ...

But what could be done to improve this is to evaluate which are the most popular 15 games, and only put them in the menu ... probably based on the number of times played, or the length of time played ... if it became an issue that could be implemented ...

M1th
02-07-2004, 04:48 PM
But what could be done to improve this is to evaluate which are the most popular 15 games, and only put them in the menu ... probably based on the number of times played, or the length of time played ... if it became an issue that could be implemented ...

now, that I like. The sql query will no doubt get abit complicated, though since you'd need to do a join table and use 'count', order by, limit etc. :)

gmarik
02-07-2004, 07:27 PM
Any chance to use it without DHTML on?

Natch
02-08-2004, 03:25 AM
Any chance to use it without DHTML on?
How would you want it - like in a Sidebar menu ? or a vBIndex custom box ?

Sure - could be done :)

BlackxRam
02-08-2004, 05:46 AM
THIS IS AWESOME LOOKING. But right now even with a dozen or so games the LIST is Huge!

I like the idea of HAVING an option like ONLY use top 5 games. or Whatever you want to make the limit. Personally I would like to use Top5 most visited Games. Someone might want to use Top 10. Perhaps a editable field in the Arcade Panel for this option.

Ill use this hack soon if it ever gets those features.

Ill keep in touch with this thread.

Natch
02-08-2004, 06:51 AM
Another option (if it is just the size of the list that is too big) is to edit the CSS statements for the navbar popup links - drop them down a fint size and it should help a lot ...

Sometimes I forget that not everyone has 1280x1024 ...

I'll look into this ok guys ?

Natch
02-10-2004, 04:58 AM
Another option (if it is just the size of the list that is too big) is to edit the CSS statements for the navbar popup links - drop them down a fint size and it should help a lot ...

Sometimes I forget that not everyone has 1280x1024 ...

I'll look into this ok guys ?
OK - I've created the new function to populate the menu with only the N most played games - atm the value of N will be hardcoded by you the hacker into your global.php (where the function is called), but for the next release (which will have this variant as an option) I will add it to the Arcade ACP Options page (once I learn how to do ACP options LOL) - I will not be updating the original instructions until the next release ...

IF YOU WANT TO HAVE ONLY N MOST POPULAR OPTIONS

Find in includes/functions.php

// Addon to John's vB3 ArcadeV3 hack - created by Natch
function genArcadeMenu() {
global $DB_site,$vboptions;
$theseGames = $DB_site->query("SELECT gameid,title,gamesettings FROM " . TABLE_PREFIX . "games ORDER BY title");
while ($thisGame = $DB_site->fetch_array($theseGames)) {
$arcmenu.= (is_int($thisGame[gamesettings]/2)) ? "" : "\t\t<tr><td class=\"vbmenu_option\"><a href=\"$vboptions[bburl]/arcade.php?$session[sessionurl]do=play&amp;gameid=".$thisGame[gameid]."\">".$thisGame[title]."</a></td></tr>\n";
}
return $arcmenu;
}
// Addon to John's vB3 ArcadeV3 hack - created by Natch


Replace with:

// Addon to John's vB3 ArcadeV3 hack - created by Natch
function genArcadeMenu($limit) {
global $DB_site,$vboptions;
$theseGames = $DB_site->query("
SELECT " . TABLE_PREFIX . "games.gameid AS gameid, " . TABLE_PREFIX . "games.title AS title, " . TABLE_PREFIX . "games.gamesettings as gamesettings, COUNT(" . TABLE_PREFIX . "gamesessions.gamename) AS popularity
FROM " . TABLE_PREFIX . "games
INNER JOIN " . TABLE_PREFIX . "gamesessions
ON " . TABLE_PREFIX . "games.shortname = " . TABLE_PREFIX . "gamesessions.gamename
GROUP BY title
ORDER BY popularity DESC
LIMIT $limit
");
while ($thisGame = $DB_site->fetch_array($theseGames)) {
$arcmenu.= (is_int($thisGame[gamesettings]/2)) ? "" : "\t\t<tr><td class=\"vbmenu_option\"><a href=\"$vboptions[bburl]/arcade.php?$session[sessionurl]do=play&amp;gameid=".$thisGame[gameid]."\">".$thisGame[title]."</a></td></tr>\n";
}
return $arcmenu;
}
// Addon to John's vB3 ArcadeV3 hack - created by Natch


Find in global.php

// Addon to John's vB3 ArcadeV3 hack - created by Natch
$nav_arcade = genArcadeMenu();
// Addon to John's vB3 ArcadeV3 hack - created by Natch


Replace with:

// Addon to John's vB3 ArcadeV3 hack - created by Natch
$nav_arcade = genArcadeMenu("6");
// Addon to John's vB3 ArcadeV3 hack - created by Natch


This should do it ... change the value in the global function call (above) to match your required number of menu options ...

Amzadi
02-10-2004, 05:51 AM
Got a screen capture of this?

Natch
02-10-2004, 08:41 AM
Check out the first post - this is just a modification of the first script ...

dirtymerc
02-11-2004, 05:35 AM
Everything worked, but my arcade button is missing, its just a drop down arrow??? www.offthetopic.com/forums

dirtymerc
02-11-2004, 06:27 AM
How can i get it so that in the postbit, it just shows trophies for the number of games that the person has won, and then when you roll over a trophy it shows which game it was for? In a horizontal fashion under the username in the new postbit setup not legacy???

Thanks a ton!

Natch
02-11-2004, 08:55 AM
Everything worked, but my arcade button is missing, its just a drop down arrow??? www.offthetopic.com/forums

Make sure you added the New Phrase, as per the instructions ...

How can i get it so that in the postbit, it just shows trophies for the number of games that the person has won, and then when you roll over a trophy it shows which game it was for? In a horizontal fashion under the username in the new postbit setup not legacy???

Thanks a ton!
That's more a question for John in his thread :) but it's a simple postbit template modification ...

Allan
02-11-2004, 09:45 AM
Thanks Natch, good work !

AshAbed
02-11-2004, 08:25 PM
I had been doing this manually.... thanks for the hack, too bad I had them added already lol,

milkmycow
03-31-2004, 04:50 PM
on the add-on for only displaying top played games, is there a way to add a link @ the bottom of list saying click here for more games? to go to arcade home?

Natch
04-01-2004, 02:38 PM
You should be able to add <a href tags pointing to the arcade home page around the title of the menu (if I didn't do it already ...)

Cold Steel
04-14-2004, 10:07 PM
Installed.

neocorteqz
04-15-2004, 04:46 AM
You should be able to add <a href tags pointing to the arcade home page around the title of the menu (if I didn't do it already ...)
I thought you did.

Natch
04-15-2004, 10:49 PM
I thought you did.
I thought so too ...

<tr><td class="thead"><a href="$vboptions[bburl]/arcade.php?$session[sessionurl]" title="$vbphrase[arcade_addon_title]">$vbphrase[arcade_addon_title]</a></td></tr>

Yup :)

There is a link already - look @ the link @ the top of the list of top games - it will be a link to the arcade ...

kall
05-23-2004, 12:30 AM
I installed this hack, but the drop-down menu won't populate.

I can call $nav_arcade manually, on a separate page, and it displays a list of all installed games, but when it is put in the drop down box in the navbar, I get nothing.

http://forums.nzboards.com (top navbar)

Does anyone have any suggestions?

WEForums
05-23-2004, 03:54 PM
Top worked for me.

kall
05-23-2004, 08:36 PM
I installed this hack, but the drop-down menu won't populate.

I can call $nav_arcade manually, on a separate page, and it displays a list of all installed games, but when it is put in the drop down box in the navbar, I get nothing.

http://forums.nzboards.com (top navbar)

Does anyone have any suggestions?
Sorted.

I had it in the 'Additional Navbar' and it really really didn't like that.

Nice hack. :)

Cyricx
06-05-2004, 08:57 AM
I just upgraded to vbadvanced and ran into the same problem Kall.

So guessing that's what is causing it.

What did you do to fix your problem?

I use ushop and the arcade so would prefer to have both autopopulating. :(

Cyricx
06-07-2004, 05:21 AM
Yep, the problem is with vbadvanced. Had vbindex and it worked fine, now at my home page www.mmogcommunities.com neither will populate, but at the forum index at www.mmogcommunities.com/forums they populate fine. I'll post to Trigga and see if he can troubleshoot the issue.

kall
06-07-2004, 05:22 AM
I just upgraded to vbadvanced and ran into the same problem Kall.

So guessing that's what is causing it.

What did you do to fix your problem?

I use ushop and the arcade so would prefer to have both autopopulating. :(
I think it was due to having another menu of the same name somewhere in the navbars...can't really remember what it was, because I decided to Revert my navbar and start again. :)

kall
06-07-2004, 10:27 AM
Yep, the problem is with vbadvanced. Had vbindex and it worked fine, now at my home page www.mmogcommunities.com neither will populate, but at the forum index at www.mmogcommunities.com/forums they populate fine. I'll post to Trigga and see if he can troubleshoot the issue.
Ahh true...Im using the CMPS thingamewotsit.

Seems the Forums Jump in navbar populates fine, as does the top part of the Ushop, but not the Actions, nor this menu.

If I come up with a solution, I'll let you know.

Natch
06-07-2004, 10:35 AM
The only reason why this would not populate would be if the functions.php is not being called, if the populate function has been removed from functions.php, or if the variable has been stolen by another bit of code ...

Cyricx
06-08-2004, 03:42 AM
Kewl Brian at http://vbadvanced.com pointed to the fix.

If you have VBadvanced cmps, and this hack isn't working, you'll need to open your vba_cmps_include_bottom.php file

And look for :
global $vboptions, $vba_options, $vbphrase, $stylevar, $bbuserinfo, $show, $pmbox;

Replace it with :
global $vboptions, $vba_options, $vbphrase, $stylevar, $bbuserinfo, $show, $pmbox, $nav_arcade;

And you'll be set to go! :)

This info came from this thread -

http://www.vbadvanced.com/forum/showthread.php?t=1182

SurreDeth
06-14-2004, 12:24 PM
Whenever I have an unregistered user click on a game in the dropdown they get the error: Could not find phrase 'quickreg_prompt'.

I have quickreg_prompt defined in the phrase manager.

EDIT: Nevermind, I found the reason :P I needed to move it to Front End error messages.

Blam Forumz
07-18-2004, 10:30 AM
:) *Installs*

Intex
07-22-2004, 01:14 PM
Nice one Natch. Any way to include the little mini-thumbnails for each game?

/me clicks install.

Natch
07-22-2004, 11:09 PM
Yeah - I should think that would be a trivial change...

Let me look into it - it would of course make the menu more massive again...

Natch
07-23-2004, 01:22 AM
OK - to add images to the menu:

Open includes/functions.php, find the query you are using (remember there are multiple versions of this query):
Original:// Addon to John's vB3 ArcadeV3 hack - created by Natch
function genArcadeMenu() {
global $DB_site,$vboptions;
$theseGames = $DB_site->query("SELECT gameid,title,gamesettings FROM " . TABLE_PREFIX . "games ORDER BY title");
while ($thisGame = $DB_site->fetch_array($theseGames)) {
$arcmenu.= (is_int($thisGame[gamesettings]/2)) ? "" : "\t\t<tr><td class=\"vbmenu_option\"><a href=\"$vboptions[bburl]/arcade.php?$session[sessionurl]do=play&amp;gameid=".$thisGame[gameid]."\">".$thisGame[title]."</a></td></tr>\n";
}
return $arcmenu;
}
// Addon to John's vB3 ArcadeV3 hack - created by Natch Replace with:// Addon to John's vB3 ArcadeV3 hack - created by Natch
function genArcadeMenu() {
global $DB_site,$vboptions,$stylevar;
$theseGames = $DB_site->query("SELECT gameid,title,gamesettings,miniimage FROM " . TABLE_PREFIX . "games ORDER BY title");
while ($thisGame = $DB_site->fetch_array($theseGames)) {
$arcmenu.= (is_int($thisGame[gamesettings]/2)) ? "" : "\t\t<tr><td class=\"vbmenu_option\"><img src=\"$vboptions[bburl]/$stylevar[imgdir_arcade]/".$thisGame[miniimage]."\" alt=\"\" style=\"border:0;padding-right:3px\" align=\"absmiddle\" /><a href=\"$vboptions[bburl]/arcade.php?$session[sessionurl]do=play&amp;gameid=".$thisGame[gameid]."\">".$thisGame[title]."</a></td></tr>\n";
}
return $arcmenu;
}
// Addon to John's vB3 ArcadeV3 hack - created by Natch

Most often played:// Addon to John's vB3 ArcadeV3 hack - created by Natch
function genArcadeMenu($limit) {
global $DB_site,$vboptions;
$theseGames = $DB_site->query("
SELECT " . TABLE_PREFIX . "games.gameid AS gameid, " . TABLE_PREFIX . "games.title AS title, " . TABLE_PREFIX . "games.gamesettings as gamesettings, COUNT(" . TABLE_PREFIX . "gamesessions.gamename) AS popularity
FROM " . TABLE_PREFIX . "games
INNER JOIN " . TABLE_PREFIX . "gamesessions
ON " . TABLE_PREFIX . "games.shortname = " . TABLE_PREFIX . "gamesessions.gamename
GROUP BY title
ORDER BY popularity DESC
LIMIT $limit
");
while ($thisGame = $DB_site->fetch_array($theseGames)) {
$arcmenu.= (is_int($thisGame[gamesettings]/2)) ? "" : "\t\t<tr><td class=\"vbmenu_option\"><a href=\"$vboptions[bburl]/arcade.php?$session[sessionurl]do=play&amp;gameid=".$thisGame[gameid]."\">".$thisGame[title]."</a></td></tr>\n";
}
return $arcmenu;
}
// Addon to John's vB3 ArcadeV3 hack - created by Natch Replace with:function genArcadeMenu($limit) {
global $DB_site,$vboptions,$stylevar;
$theseGames = $DB_site->query("
SELECT games.gameid AS gameid, games.title AS title, games.gamesettings as gamesettings, games.miniimage AS miniimage, COUNT(gamesessions.gamename) AS popularity
FROM " . TABLE_PREFIX . "games as games
INNER JOIN " . TABLE_PREFIX . "gamesessions AS gamesessions
ON games.shortname = gamesessions.gamename
GROUP BY title
ORDER BY popularity DESC
LIMIT $limit
");
while ($thisGame = $DB_site->fetch_array($theseGames)) {
$arcmenu.= (is_int($thisGame[gamesettings]/2)) ? "" : "\t\t<tr><td class=\"vbmenu_option\"><img src=\"$vboptions[bburl]/$stylevar[imgdir_arcade]/".$thisGame[miniimage]."\" alt=\"\" style=\"border:0;padding-right:3px\" align=\"absmiddle\" /><a href=\"$vboptions[bburl]/arcade.php?$session[sessionurl]do=play&amp;gameid=".$thisGame[gameid]."\">".$thisGame[title]."</a></td></tr>\n";
}
return $arcmenu;
}


Open global.php, find:// Addon to Erwin's vB3 Flash hack - created by Natch
$nav_arcade = genArcadeMenu("9");MOVE THESE LINES DOWN TO BELOW:// ################################################## ###########################
// get style variables
$stylevar = fetch_stylevars($style, $bbuserinfo);

Hope this is useful to y'all :D

Intex
07-23-2004, 04:30 AM
Adding the images to the menu works perfect for me Natch. Good job, thx. Natch.

Natch
07-23-2004, 06:14 AM
NP :) good idea :D

Tombstone
10-25-2004, 11:55 AM
As soon as I edit the functions.php file I loose access to the site (i.e. blank page). I'm doing just a simple cut and paste using notepad.

Tombstone
10-25-2004, 12:13 PM
Any ideas?

Natch
10-25-2004, 12:54 PM
Sounds like you are either copying and pasting too much code, or not enough.

Nothing in this code would cause you to get that kind of error, unless you are fundamentally altering the name of the final template name...

Revert to your backup'ed file, then make the alterations more carefully..., or send me your original file and your altered file and I'll work it out for you.

Tombstone
10-25-2004, 02:10 PM
How can I send it to you? Post it?

jugo
05-25-2005, 08:13 PM
OK...so I wanted to display 10 Random Arcades on MY list so this is what I did...

Apply the changes for the Most Played Games and change the query to this:

$theseGames = $DB_site->query("SELECT gameid,title,gamesettings FROM " . TABLE_PREFIX . "games ORDER BY RAND() LIMIT $limit");