|
Viewing Single Post From: Add more links to Submenu
|
|
Reid.
|
Jun 23 2009, 04:32 PM
|
- Posts:
- 377
- Group:
- Members
- Member
- #147,240
- Joined:
- February 13, 2007
- I'm Browsing With
- Firefox 3
- My Board URL
- http://resources.zetaboards.com/
|
This allows you to add as many links to the submenu as necessary. It does require a bit of setup, but it isn't really hard.
First: you have to decide if you want the link to come before or after the links that are already there (search, members, .... etc.) This isn't really hard to do either. You can chose quite a few options.
So here we go. Here's the code. - Code:
-
<script type='text/javascript'> // <![CDATA[ var links = [], n = 0; //start editing here var before = false; links[n++] = ['http://www.google.com/','Google','before']; links[n++] = ['http://www.yahoo.com/','Yahoo']; links[n++] = ['http://if.invisionfree.com/','Support Board']; //your ride ends here. :( //if you do know how to edit this, feel free to, though. var l = links.length; while (l--){ var c = document.getElementById('submenu'), urlstr = "<a href='" + links[l][0] + "'>" + links[l][1] + "</a>"; if (before && links[l][2] && links[l][2].toLowerCase().indexOf("after") == -1) c.innerHTML = urlstr + " " + c.innerHTML; else if (before && links[l][2] && links[l][2].toLowerCase().indexOf("after")!=-1) c.innerHTML += " " + urlstr; else if (before && !links[l][2]) c.innerHTML = urlstr + " " + c.innerHTML; else if (links[l][2] && links[l][2].indexOf("before")!=-1) c.innerHTML = urlstr + " " + c.innerHTML; else c.innerHTML += " " + urlstr; } // ]]> </script> Okay... looks like a lot, right? It's not THAT bad.
See the part that says - Code:
-
var before = false; ? That's where the setup starts.
Basically... you can chose if you want all links to go before the links or not. If you want them all to go before, change that to - Code:
-
var before = true; If not, just leave it how it is.
Here comes the adding links part. So here's the basic format: - Code:
-
links[n++] = ['url to link','What you want the link to say','before or after (optional)']; Be sure not to get your commas and quotation marks mixed up - this is coding, not grammar, so the comma will go after the quotation mark most of the time.
You can add more or less of these links as needed. Here's another example: Spoiler: click to toggle - Code:
-
<script type='text/javascript'> // <![CDATA[ var links = [], n = 0; //start editing here var before = true; links[n++] = ['http://www.google.com/','Google']; links[n++] = ['http://www.yahoo.com/','Yahoo']; links[n++] = ['http://if.invisionfree.com/','Support Board']; links[n++] = ['http://www.bing.com/','Bing']; links[n++] = ['http://www.w3schools.com/','Learn Coding!','after']; //your ride ends here. :( //if you do know how to edit this, feel free to, though. var l = links.length; while (l--){ var c = document.getElementById('submenu'), urlstr = "<a href='" + links[l][0] + "'>" + links[l][1] + "</a>"; if (before && links[l][2] && links[l][2].toLowerCase().indexOf("after") == -1) c.innerHTML = urlstr + " " + c.innerHTML; else if (before && links[l][2] && links[l][2].toLowerCase().indexOf("after")!=-1) c.innerHTML += " " + urlstr; else if (before && !links[l][2]) c.innerHTML = urlstr + " " + c.innerHTML; else if (links[l][2] && links[l][2].indexOf("before")!=-1) c.innerHTML = urlstr + " " + c.innerHTML; else c.innerHTML += " " + urlstr; } // ]]> </script>
This example adds all of the URLs before the main links, except the 'Learn Coding!' one, which it adds after. If there are any questions setting it up, feel free to post in this topic or PM me on this or any board you may find me on.
And, another example, just for you guys. Spoiler: click to toggle - Code:
-
<script type='text/javascript'> // <![CDATA[ var links = [], n = 0; //start editing here var before = true; links[n++] = ['http://lmgtfy.com/?q=irc+client','IRC client','after']; //your ride ends here. :( //if you do know how to edit this, feel free to, though. var l = links.length; while (l--){ var c = document.getElementById('submenu'), urlstr = "<a href='" + links[l][0] + "'>" + links[l][1] + "</a>"; if (before && links[l][2] && links[l][2].toLowerCase().indexOf("after") == -1) c.innerHTML = urlstr + " " + c.innerHTML; else if (before && links[l][2] && links[l][2].toLowerCase().indexOf("after")!=-1) c.innerHTML += " " + urlstr; else if (before && !links[l][2]) c.innerHTML = urlstr + " " + c.innerHTML; else if (links[l][2] && links[l][2].indexOf("before")!=-1) c.innerHTML = urlstr + " " + c.innerHTML; else c.innerHTML += " " + urlstr; } //]]> </script>
This one adds a link after the main stuff to google. The link says 'IRC client.' And so on.
Good luck!
|
|
|