MoMan |
09-03-2010 10:00 PM |
Style Switcher like on vB.org
1 Attachment(s)
I've written a simple JS function that can be used if you want to implement a style selector like on vB.org (using colored icons instead of a dropdown).
Simply add this to vbulletin_global.js, or include it in your footer template:
Code:
function switch_style(F)
{
E = "style";
if(F == "")
{
return;
}
var B=new String(window.location);
var A=new String("");
B=B.split("#");
if(B[1])
{
A="#"+B[1]
}
B=B[0];
if(B.indexOf(E+"id=")!=-1&&is_regexp)
{
var D=new RegExp(E+"id=\\d+&?");
B=B.replace(D,"")
}
if(B.indexOf("?")==-1)
{
B+="?"
}
else
{
lastchar=B.substr(B.length-1);
if(lastchar!="&"&&lastchar!="?")
{
B+="&"
}
}
window.location=B+E+"id="+F+A
}
Then, you'd use something like this in your footer template:
HTML Code:
<a onclick="switch_style('9');return false;" href="$vboptions[bburl]/index.php?styleid=9" rel="nofollow"><img src="$vboptions[bburl]/images/redstyle.gif" alt="" title="Red Layout" border="0" width="13" height="13" class="inlineimg" /></a>
This will then switch your style to an ID of your choice (9 in the example above). You will have to have separate styles for each color you want to switch between.
Hope someone will find this useful! Enjoy!
|