Go Back   vb.org Archive > vBulletin 5 Connect Discussion > vB5 Programming Discussions
  #1  
Old 08-09-2014, 04:14 AM
kupendran kupendran is offline
 
Join Date: Aug 2014
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default How to add "Drop Down Sub Navigation" Function

I Want to add my sub navigation list as drop down format like when we over the cursor on the main menu, Its should be show the sub navigation list in that drop down list.

So, Is there any option to modify the default sub navigation menu details to drop down list navigation in vbulletin 5?
Reply With Quote
  #2  
Old 08-25-2014, 10:21 AM
sn1p3r001 sn1p3r001 is offline
 
Join Date: Jun 2013
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I haven't found a way to do this and utilize the built-in nav manager to set up the links, but I did one with some CSS and HTML additions to templates. OBviously this isn't ideal, but if you really need the drop downs for aesthetic or accessibility reasons, this will probably do the trick until it becomes a feature in VB5. Below is a copy of mine. You can see it in action here:

http://vb5.luckyshotgaming.com

First we have our HTML for the navbar options. Customize this as needed. It's pretty straightforward. All Caps are the main menu items. The lowercase ones below are the sub items. You need to put the URLs to your pages where the #s are.
Code:
<ul id="customdropdownnav">
    
      <li>
        <a href="#">HOME</a>
      </li>

     <li>
        <a href="#">FORUMS</a>
    </li>

       
    <li>
        <a href="#">OUR COMMUNITY</a>
        <ul>
            <li><a href="#">Ranks</a></li>            
            <li><a href="#">Awards</a></li>
            <li><a href="#">Rules</a></li>
            <li><a href="#">Structure</a></li>
            <li><a href="#">Steam Group</a></li>
            <li><a href="#">Battlelog Platoon</a></li>
        </ul>
    </li>
    
    <li>
        <a href="#">SERVERS</a>
        <ul>
            <li><a href="#">Server Information</a></li>
            <li><a href="#">Leaderboards</a></li>
            
        </ul>
    </li>
    
    <li>
        <a href="#">LINKS</a>
        <ul>
            <li><a href="#">Link 1</a></li>
            <li><a href="#">Link 2</a></li>

        </ul>
    </li>
</ul>
Then the CSS. You will have to go through and change things to meet your color needs. It's pretty well commented, so it should be easy enough. This was based on the default style for vb5, with some minor color adjustments.

Code:
/*---NAV --- */
#customdropdownnav{
    list-style:none;
    font-weight:bold;
    margin-bottom:10px;
    float:left; /* Clear floats */
    width:100%;
    /* Bring the nav above everything else--uncomment if needed.
    position:relative;
    z-index:5;
    */
}
#customdropdownnav li{
    float:left;
    margin-right:0px;
    position:relative;
}
#customdropdownnav a{ /* Change properties of main menu items */
    display:block;
    padding-left:17px;
    padding-right:17px;
    padding-top:10px;
    padding-bottom:10px;
    color:#fff;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
    background-image: url("http://www.vb5.luckyshotgaming.com/images/menugradient.png"); /* Change this if your navbar has a background image. Remove it if it doesn't */
    text-decoration:none;
}
#customdropdownnav a:hover{ /* Change properties of main menu items when you hover over them */
    color:#fff;
    background:#2379b5;
        text-decoration:none;
}

/*--- DROPDOWN ---*/
#customdropdownnav ul{
    background:#fff; /* For IE7+ compatibility. Make this as close to your page's background as possible. */
    background:rgba(255,255,255,0); /*Makes said background transparent when possible. */
    list-style:none;
    position:absolute;
    left:-9999px; /* DO NOT EDIT */
}
#customdropdownnav ul li{
    padding-top:1px; /* Changes spacing between the sub-items spaced items */
    float:none;
}
#customdropdownnav ul a{
    white-space:nowrap; /* Stop text wrapping and creating multi-line dropdown items */
}
#customdropdownnav li:hover ul{ /* Display the dropdown on hover*/
    left:0; 
}
#customdropdownnav li:hover a{ /* Change color of main menu item when hovering over a sub item */
    background:#2379b5;
    color:#ffffff;
    text-decoration:none;
}
#customdropdownnav li:hover ul a{ /* The persistent hover state does however create a global style for links even before they're hovered. Here we undo these effects. */
    text-decoration:none;
}
#customdropdownnav li:hover ul li a:hover{ /* Change individual dropdown hover colors */
    background:#ffffff;
    color:#2379b5;
}


To install this:
  1. BACK UP your header and additional css templates. Copy and paste everything and save it somewhere in case something goes screwy.
  2. Add the CSS to the additional css template.
  3. Copy and paste the HTML into the header template where the current nav bar is (I searched fand overwrote the current one. This eliminated the nav bar and the subnav.)


If you're not too great with code, there are some neat website out there like JSFiddle that you can copy and paste the codes above into, tweak, and see how your changes modify the outcome BEFORE you put it on your site. I would recommend trying one if you're not code savvy.


Keep in mind that an edit like this will require manual header changes in order to keep the nav menu up to date. Editing in the built-in nav manager WILL NOT update this bar. It must be done by hand through the header template. I know it's not perfect, but it's quick and dirty fix until it's a feature.
Reply With Quote
Благодарность от:
Lynne
  #3  
Old 01-03-2016, 02:14 PM
ChristianAlfred ChristianAlfred is offline
 
Join Date: Nov 2007
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is there a way to use only CSS and not change headercode?
Reply With Quote
Reply

Thread Tools
Display Modes

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 11:25 AM.


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.03389 seconds
  • Memory Usage 2,183KB
  • Queries Executed 11 (?)
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)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (1)post_thanks_box_bit
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)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
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete