Joined: Nov 2010 Gender: Male Posts: 976 Location: California Karma: 53
Add Menu Buttons « Thread Started on Nov 15, 2011, 10:55am »
Hey guys.
I've been looking for a code that will allow me to add more menu buttons to my forum, but I would also like it to be multiple skin compatible (var statements maybe?), and if possible have an option to let you choose if the new menu button will be visible to guests or members only.
Anyone know of a code out there?
« Last Edit: Feb 19, 2012, 9:09am by GFX Support »
Joined: Apr 2009 Gender: Male Posts: 1,962 Karma: 75
Re: Add Menu Buttons « Reply #1 on Nov 15, 2011, 12:30pm »
Wormo's code will give you the option to add several extra buttons, at any desired place, and has an option to hide them from guests. It's not multiple skin compatible, but if you ask him nicely I'm pretty sure he'll be able to add that feature.
I'm off duty! For questions or support please contact RADesign or Speed Demon.
Pebble Code Helper IOD Supporter member is offline
Joined: Mar 2011 Gender: Male Posts: 1,180 Location: Here & There Karma: 155
Re: Add Menu Buttons « Reply #2 on Nov 15, 2011, 12:56pm »
Hi OJ,
you can try this:
Code:
<script type="text/javascript"> /* Add buttons to menu bar if skinid and if guest */ <!-- var gv=0; // guest viewable = 1 not viewable = 0 var sv=1; // skinid viewable if(pb_skinid==sv){if(((pb_username=="Guest")&&(gv==1))||(pb_username!=="Guest")){document.getElementsByTagName("font" )[3].innerHTML+='<a href="http://www.pebbleleague.com/index.cgi?action=display&board=forumrules&thread=47&page=1#7978"><img src="http://i1136.photobucket.com/albums/n494/pebbleleague/menubuttons2/donate_off.png" border="0" alt="Donate"></a> '; } } // --> </script>
Obviously replacing my url to the button. Vars are self explanatary. You can repeat the code for each button and putting in the relevant vars. I've tried this in IE and FF and it works with Sub's customize menu bar code. (I haven't tried the flash version but I assume it's the same code for the menu bar). Put it above Subs menubar customize. ---------------------------------------------------------------------------------------------
I started knocking up this code which will be more user friendly (all the info will go in the vars at the top and just run a looped code) but it wasn't working in IE9 for some reason and I've run out of time: If anyone wants to mod it , feel free or I'll get back to it at the weekend some time.
Code:
<script type="text/javascript"> <!-- /* Add buttons to menu bar */ /* [skinid , Guestviewable=1 , url to button] */ var eb=[ [1,1,'urltobuttonONE'], [1,0,'urltobuttonTWO'] ]; ETC ETC for(var x=0;x<eb.length;x++){ if((pb_skinid==eb[x][0])&&(gv==eb[x][1])) {document.getElementsByTagName("font")[3].innerHTML+=eb[x][2]}}; --> </script>
Pebble.
EDIT: I've seen where I was going wrong and will re-do it at the weekend.
Pebble Code Helper IOD Supporter member is offline
Joined: Mar 2011 Gender: Male Posts: 1,180 Location: Here & There Karma: 155
Re: Add Menu Buttons « Reply #4 on Nov 15, 2011, 8:04pm »
Code:
<script type="text/javascript"> /* Add buttons to menu bar if skinid and if guest */ <!-- var gv=0; // guest viewable = 1 not viewable = 0 var sv=1; // skinid viewable if(pb_skinid==sv){if(((pb_username=="Guest")&&(gv==1))||(pb_username!=="Guest")){document.getElementsByTagName("font" )[3].innerHTML+='<a href="URL TO BUTTON DESTINATION"><img src="URL TO BUTTON IMAGE SOURCE" border="0" alt="HOVER TEXT FOR BUTTON"></a> '; } } // --> </script>
Joined: Nov 2010 Gender: Male Posts: 976 Location: California Karma: 53
Re: Add Menu Buttons « Reply #5 on Nov 16, 2011, 2:12am »
Ah very nice Pebble! Works perfectly. Thanks alot bro. Now would it be possible for you to make it all, so that I only have to use the code once, instead of having to put in a new copy for each one?
var i=0; for (i=0;i<eb.length;i++){ if(pb_skinid==eb[i][0]){if((pb_username!=="Guest")||((pb_username=="Guest")&&(eb[i][1]==1))){ document.getElementsByTagName("font" )[3].innerHTML+=eb[i][2]; } } } </script>
The code looks really small now lol
Add or delete the [a,b,c] rows as needed (no comma after last one) Dont forget the ' before and after the 3rd value in each row. I've tried it with Sub's menu bar customize code in IE9 and FF.
I'm not sure if it's easier to leave the 3rd value as it is (the same as it is copied from photobucket html code selection) or to add another value so you can enter the image source and button URL destination seperately. Let me know what you think.
/* DON'T TOUCH BELOW HERE */ var i=0; for (i=0;i<eb.length;i++){ if(pb_skinid==eb[i][0]){if((pb_username!=="Guest")||((pb_username=="Guest")&&(eb[i][1]==1))){ document.getElementsByTagName("font" )[3].innerHTML+=' <a href="'+eb[i][2]+'"><img src="'+eb[i][3]+'" border="0" alt="'+eb[i][4]+'">'; } } } </script>
Tried and tested in IE and FF with subs code.
RAD - If all goes well when OJ tries it out , I'll clean it up and write some instructions for it - I've no problem at all with it been added to IOD's data base (though it's not really in the same league as Sub's codes and looks a bit meagre in comparison !)
Pebble Code Helper IOD Supporter member is offline
Joined: Mar 2011 Gender: Male Posts: 1,180 Location: Here & There Karma: 155
Re: Add Menu Buttons « Reply #13 on Nov 19, 2011, 2:41pm »
Hi OJ, I've just made a little modification so that it works the same in all browsers. Just replace the code you have beneath the 'DO NOT TOUCH' with the code beneath the same heading below. The variables for each button are the same so you don't need to replace those. And it's all finished and tidied up !
Code:
<script type="text/javascript"> /* extra buttons if guest and if skin */ /* [a,b,'c','d','e'] */ /* [ skinid , guest viewable =1/not guest viewable = 0 , 'url to button destination' , 'url to image source' , 'hover text'] , */ /* example: [1,1,'http://s1136.photobucket.com/albums/n494/pebbleleague/menubuttons2/?action=view¤t=5members_off.png','http://i1136.p hotobucket.com/albums/n494/pebbleleague/menubuttons2/5members_off.png','TESTEROOONY'] , */