Go Back   vb.org Archive > vBulletin Modifications > vBulletin 3.8 Modifications > vBulletin 3.8 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Style Switcher like on vB.org Details »»
Style Switcher like on vB.org
Version: 1.00, by MoMan MoMan is offline
Developer Last Online: Oct 2022 Show Printable Version Email this Page

Category: Miscellaneous Hacks - Version: 3.8.6 Rating:
Released: 09-03-2010 Last Update: Never Installs: 9
Template Edits
Re-useable Code Code Changes  
No support by the author.

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!

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
Благодарность от:
DePReM11

Comments
  #12  
Old 07-22-2011, 10:23 PM
8thos's Avatar
8thos 8thos is offline
 
Join Date: Aug 2010
Location: Pensacola, FL
Posts: 772
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I'll PM MoMan then.
Reply With Quote
  #13  
Old 07-23-2011, 02:47 AM
great kitten great kitten is offline
 
Join Date: Mar 2010
Posts: 38
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

screenshots please
Reply With Quote
  #14  
Old 07-23-2011, 02:57 AM
8thos's Avatar
8thos 8thos is offline
 
Join Date: Aug 2010
Location: Pensacola, FL
Posts: 772
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by great kitten View Post
screenshots please
Scroll down to the bottom of the page. Do you see the style switcher? That's what it looks like.
Reply With Quote
  #15  
Old 07-23-2011, 11:20 AM
8thos's Avatar
8thos 8thos is offline
 
Join Date: Aug 2010
Location: Pensacola, FL
Posts: 772
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

It works in vb4. He just gave bad directions, that's all.

Put this javascript in your headinclude or footer.


HTML Code:
<script type="text/javascript" src="clientscript/vbulletin_global.js">
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
}</script>
Reply With Quote
  #16  
Old 07-23-2011, 05:46 PM
8thos's Avatar
8thos 8thos is offline
 
Join Date: Aug 2010
Location: Pensacola, FL
Posts: 772
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Same code but compressed to reduce page load time.

HTML Code:
<script type="text/javascript"src="clientscript/vbulletin_global.js">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}</script>
Reply With Quote
  #17  
Old 07-26-2011, 10:04 AM
MoMan MoMan is offline
 
Join Date: Oct 2005
Location: USA
Posts: 301
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Of course it works- all this function does is it redirects your browser

BTW, in your above code, you should get rid of the src="clientscript/vbulletin_global.js" attribute.

Does vb4 not use vbulletin_global.js?
Reply With Quote
  #18  
Old 02-18-2012, 12:31 PM
dany_danay dany_danay is offline
 
Join Date: Jul 2009
Posts: 142
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Work in vb4?How can i get this on the header?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:44 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06142 seconds
  • Memory Usage 2,301KB
  • Queries Executed 23 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_code
  • (3)bbcode_html
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (8)post_thanks_box
  • (1)post_thanks_box_bit
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (8)post_thanks_postbit_info
  • (7)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete