2008-12-28, 04:12 PM
For those wondering what this is, this code modification allows your MyBB forum to have a vBulletin-style feature, drop down navigation, for both the search box and the User CP.
The original plugin - Conditional and vb navbar for 1.20 - was released by Lapsetur and all I have done here is to tidy it up and tweak it a little so that it looks and works fine for MyBB 1.4.4+.
In other words, the actual code released by Lapsetur that drives the plugin *still* works in MyBB 1.4.4+. The only difference is the additional modifications to bring it up to date - display wise and link edits - for MyBB 1.4.4+.
Files that you need
You can find all the files at the end of this post, but this is what you need to do with them:
The next step is to edit the template of your theme. I have used the default theme for my example, but hopefully it should work with other themes as well. Replace the contents of each template with the code below:
Header Templates / header
Header Templates / header_welcomeblock_guest
Header Templates / header_welcomeblock_member
Header Templates / header_welcomeblock_member_admin
Header Templates / header_welcomeblock_member_moderator
Ungrouped Templates / headerinclude
Forum Bit Templates / forumbit_depth2_forum
Navigation Templates / nav
Navigation Templates / nav_sep
Navigation Templates / nav_sep_active
The next step is to create a new .css file to add to your theme.
vbnavbar.css
Any corrections are welcome so please let me know if this works or doesn't work for you.
Some screenshots of the code modification in action can be seen below:
Guest view:
Admin view:
Admin/Member CP view:
Admin/Member Search view:
Condition and vbnavbar live samples
Screenshots and links to sites that use this code modification on their forums. Thanks to okitai for his permission to allow us to feature his forum here!
Admin: okitai
Forum URL: http://www.ithelp.co.il/
Comments: okitai has actually extended the functionality of the code modification by adding icons for each item in the navigation menu and customising the sub-menus as well, which you can read about here.
------------------------
CHANGELOG
Jan 7th 2009: Minor corrections to vbnavbar.css and headerinclude (Details in post #19)
March 26th 2009: Minor correction to header (Details in post #50)
April 26th 2009: New functions.php for MyBB 1.4.5 (Details in post #59)
July 1st 2009: New functions.php and class_templates.php uploaded for MyBB 1.4.8. Existing users do not need to change to this new version.
December 10th 2009: New functions.php uploaded for MyBB 1.4.10.
April 22nd 2010: New functions.php uploaded for MyBB 1.4.13.
August 4th 2010: Minor modifications to vbnavbar.css and templates header and header_welcomeblock_member (Details in post #110)
------------------------
Known Bugs
New users using IE7 (and IE6) trying to register on the Forums may experience a Passwords must match error. This is because these versions of the browser are unable to handle two sets of password boxes on the same page: one set from the registration section, and the other from this code modification.
Current known solutions are to:
1. Set up 'send random password instead of allowing users to create their own password
2. Ask new users to type the password into the topright login password box as well.
------------------------
FAQs
Q: Guests can see the 'Private messages' menu option although there is a random {1} and {2} instead of any actual values?
A: Please ensure that you download class_templates.php below and replace this file with the one in your /inc folder (clearer instructions in Step 1) The specific difference between the standard MyBB and the download below can be found in this post.
Q: How can I change the background colour of my logo header to [insert name of colour]?
A: By default, the template edits above sets the default background colour to white, so if you would like to change this (like indigored) to something else, please look for this line
An example can be found here
Q: How can I change the font or text colour of my User CP dropdown menu to [insert name of colour]?
A: The text colour is inherited from the class tcat so to override this, you will need to add a few extra lines to vbnavbar.css. This question came about as a user had a white font against their white background (you can find the original reply here) and the necessary change was as follows:
The original plugin - Conditional and vb navbar for 1.20 - was released by Lapsetur and all I have done here is to tidy it up and tweak it a little so that it looks and works fine for MyBB 1.4.4+.
In other words, the actual code released by Lapsetur that drives the plugin *still* works in MyBB 1.4.4+. The only difference is the additional modifications to bring it up to date - display wise and link edits - for MyBB 1.4.4+.
Files that you need
- Std files for 1.4.x.zip
- functions.php
- class_templates.php
You can find all the files at the end of this post, but this is what you need to do with them:
- Upload functions.php to /inc
- Upload class_templates.php to /inc
- Extract the contents of the zip file to your local drive
- Upload the 4 .gif image files in /images to /images
- Upload the 2 .js files in /jscripts to /jscripts
The next step is to edit the template of your theme. I have used the default theme for my example, but hopefully it should work with other themes as well. Replace the contents of each template with the code below:
Header Templates / header
<script language="Javascript" type="text/javascript">
var newpm_prompt = "{$lang->newpm_prompt}";
var quickdelete_confirm = "{$lang->quickdelete_confirm}";
</script>
<div id="container">
<a name="top"id="top"></a>
<div id="header">
<div class="logo" style="background:#fff url('$theme[imgdir]/logobg.gif');"><a href="{$mybb->settings['bburl']}/index.php"><img src="{$theme['logo']}" alt="{$mybb->settings['bbname']}" border="0" /></a></div>
<br />
<!-- breadcrumb, login, pm info -->
<table class="tborder" cellpadding="$theme[tablespace]" cellspacing="$theme[borderwidth]" border="0" width="100%" align="center">
<tr>
<td class="trow1" width="100%">
<table cellpadding="0" cellspacing="0" border="0">
<tr valign="bottom">
<td> </td>
<td width="100%"><navigation></td>
</tr>
</table>
</td>
<if condition=$mybb->user['uid']> 0 <then>
<td class="trow1" valign="top" nowrap="nowrap">
<div class="smalltext">
$lang->welcome_back<br />
<a href="private.php">$lang->welcome_pms</a> $lang->welcome_pms_usage<br />
$lang->welcome_current_time
</div>
</td>
<else />
<td class="trow1" nowrap="nowrap" style="padding:0px">
<!-- login form -->
<form action="member.php" method="post">
<table cellpadding="0" cellspacing="3" border="0" class="trow1">
<tr>
<td class="smalltext">$lang->username</td>
<td><input type="text" name="username" size="10" title="$lang->username" value="Username" onfocus="this.value=''" /></td>
</tr>
<tr>
<td class="smalltext">$lang->password</td>
<td><input type="password" name="password" size="10" title="$lang->password" value="$lang->password" onfocus="this.value=''" /></td>
<td><input type="submit" class="smalltext" style="font-weight:normal" value="OK" /></td>
</tr>
</table>
<input type="hidden" name="action" value="do_login" />
<input type="hidden" name="url" value="" />
</form>
<!-- / login form -->
</td>
</if>
</tr>
</table>
<!-- / breadcrumb, login, pm info -->
<table cellpadding="5" cellspacing="0" border="0" width="100%" class="tvbnav" align="center">
<tr>
<td class="tcat" align="center">{$welcomeblock}</td>
<td class="tcat" align="center"><a href="{$mybb->settings['bburl']}/index.php"><strong>Index</strong></a></td>
<td class="tcat" align="center">
<a href="{$mybb->settings['bburl']}/search.php" id="search" onclick="return openMenu(this)" class="popup_button">{$lang->toplinks_search}<img src="images/popup_down.gif" border="0" /></a></td>
<td class="tcat" align="center"><a href="{$mybb->settings['bburl']}/memberlist.php"><strong>{$lang->toplinks_memberlist}</strong></a></td>
<td class="tcat" align="center"><a href="{$mybb->settings['bburl']}/calendar.php"><strong>{$lang->toplinks_calendar}</strong></a></td>
<td class="tcat" align="center"><a href="{$mybb->settings['bburl']}/misc.php?action=help"><strong>{$lang->toplinks_help}</strong></a></td>
$admincplink
$modcplink
<if condition=$mybb->user['uid']> 0 <then>
<td class="tcat" align="center"> <a href="{$mybb->settings['bburl']}/member.php?action=logout&logoutkey={$mybb->user['logoutkey']}"><strong>$lang->welcome_logout</strong></a></td><else /></if>
</tr></table>
<hr class="hidden" />
</div>
<hr class="hidden" />
<div id="content">
{$pm_notice}
{$bannedwarning}
{$bbclosedwarning}
{$unreadreports}
<!-- header quick search form -->
<div class="menupop" id="search-popup" style="display:none">
<table cellpadding="4" cellspacing="1" border="0" class="tvbnavsearch">
<tr>
<td class="tcat">Search</td>
</tr>
<tr>
<td class="row">
<form method="post" action="$settings[bburl]/search.php">
<input type="hidden" name="action" value="do_search" />
<input type="hidden" name="postthread" value="1" />
<input type="hidden" name="forums" value="all" />
<input type="hidden" name="showresults" value="threads" />
<input type="text" name="keywords" value="" />
$gobutton
</form>
</td>
</tr>
<tr>
<td class="menu_row"><a href="search.php">Advanced Search</a></td>
</tr>
</table>
</div>
<!-- / header quick search form -->
<br />
Header Templates / header_welcomeblock_guest
<a href="{$mybb->settings['bburl']}/member.php?action=register"><strong>{$lang->welcome_register}</strong></a>
Header Templates / header_welcomeblock_member
<a href="usercp.php" id="usercp" onclick="return openMenu(this)" class="popup_button">User CP<img src="images/popup_down.gif" border="0" /></a>
<!-- user cp tools menu -->
<div class="menupop" id="usercp-popup" style="display:none">
<table cellpadding="4" cellspacing="1" border="0" class="tvbnavcp">
<tr><td class="tcat">Quick Links</td></tr>
<tr><td class="menu_row"><a href="search.php?action=getnew" title="View New Posts">{$lang->welcome_newposts}</a></td></tr>
<tr><td class="menu_row"><a href="{$mybb->settings['bburl']}/search.php?action=getdaily" title="View Today's Posts">{$lang->welcome_todaysposts}</a></td></tr>
<tr><td class="menu_row"><a href="misc.php?action=markread" title="Mark All Forums Read">Mark All Forums Read</a></td></tr>
<tr><td class="menu_row"><a href="#" onclick="MyBB.popupWindow('{$mybb->settings['bburl']}/misc.php?action=buddypopup', 'buddyList', 350, 350);" title="Open Buddy/Ignore List">Buddy/Ignore List</a></td></tr>
<tr><td class="tcat"><a href="{$mybb->settings['bburl']}/usercp.php" title="User Control Panel">User Control Panel</a></td></tr>
<tr><td class="menu_row"><a href="usercp.php?action=editsig" title="Change Signature">Change Signature</a></td></tr>
<tr><td class="menu_row"><a href="usercp.php?action=avatar" title="Change Avatar">Change Avatar</a></td></tr>
<tr><td class="menu_row"><a href="usercp.php?action=profile" title="Edit Profile">Edit Profile</a></td></tr>
<tr><td class="menu_row"><a href="usercp.php?action=options" title="Edit Options"">Edit Options</a></td></tr>
<tr><td class="tcat">Miscellaneous</td></tr>
<tr><td class="menu_row"><a href="private.php" title="View Private Messages">Private Messages</a></td></tr>
<tr><td class="menu_row"><a href="usercp.php?action=subscriptions" title="Subscribed Threads">Subscribed Threads</a></td></tr>
<tr><td class="menu_row"><a href="member.php?action=profile&uid={$mybb->user['uid']}" title="View Profile">View Profile</a></td></tr>
</table>
</div>
Header Templates / header_welcomeblock_member_admin
<td class="tcat" align="center"><a href="{$mybb->settings['bburl']}/{$config['admin_dir']}/index.php"><strong>{$lang->welcome_admin}</strong></a></td>
Header Templates / header_welcomeblock_member_moderator
<td class="tcat" align="center"><a href="{$mybb->settings['bburl']}/modcp.php"><strong>{$lang->welcome_modcp}</strong></a></td>
Ungrouped Templates / headerinclude
<link rel="alternate" type="application/rss+xml" title="{$lang->latest_threads} (RSS 2.0)" href="{$mybb->settings['bburl']}/syndication.php" />
<link rel="alternate" type="application/atom+xml" title="{$lang->latest_threads} (Atom 1.0)" href="{$mybb->settings['bburl']}/syndication.php?type=atom1.0" />
<meta http-equiv="Content-Type" content="text/html; charset={$charset}" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/prototype.js?ver=1400"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/general.js?ver=1400"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/popup_menu.js?ver=1400"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/menu.js"></script>
<script type="text/javascript" src="{$mybb->settings['bburl']}/jscripts/mybb.js"></script>
{$stylesheets}
<script type="text/javascript">
<!--
var cookieDomain = "{$mybb->settings['cookiedomain']}";
var cookiePath = "{$mybb->settings['cookiepath']}";
var cookiePrefix = "{$mybb->settings['cookieprefix']}";
var deleteevent_confirm = "{$lang->deleteevent_confirm}";
var removeattach_confirm = "{$lang->removeattach_confirm}";
var loading_text = '{$lang->ajax_loading}';
var saving_changes = '{$lang->saving_changes}';
var use_xmlhttprequest = "{$mybb->settings['use_xmlhttprequest']}";
var my_post_key = "{$mybb->post_code}";
var imagepath = "{$theme['imgdir']}";
// -->
</script>
{$newpmmsg}
Forum Bit Templates / forumbit_depth2_forum
<tr>
<td class="{$bgcolor}" align="center" valign="middle" width="1"><img src="{$theme['imgdir']}/{$lightbulb['folder']}.gif" alt="{$lightbulb['altonoff']}" title="{$lightbulb['altonoff']}" class="ajax_mark_read" id="mark_read_{$forum['fid']}" /></td>
<td class="{$bgcolor}" valign="middle">
<strong><a href="{$forum_url}">{$forum['name']}</a></strong>{$forum_viewers_text}<div class="smalltext">{$forum['description']}{$modlist}{$subforums}</div>
</td>
<td class="{$bgcolor}" valign="middle" align="center" style="white-space: nowrap">{$threads}{$unapproved['unapproved_threads']}</td>
<td class="{$bgcolor}" valign="middle" align="center" style="white-space: nowrap">{$posts}{$unapproved['unapproved_posts']}</td>
<td class="{$bgcolor}" valign="middle" align="right" style="white-space: nowrap">{$lastpost}</td>
</tr>
Navigation Templates / nav
<div class="navigation">
<img style="vertical-align:bottom;" src="$theme[imgdir]/nav_start.gif" />{$nav}{$activesep}{$activebit}
</div>
Navigation Templates / nav_sep
>
Navigation Templates / nav_sep_active
<br /><img style="vertical-align:bottom;" src="$theme[imgdir]/nav_end.gif" />
The next step is to create a new .css file to add to your theme.
Quote:Click on Themes->Name of your theme, e.g. Default->Add Stylesheet
Filename: vbnavbar.css
Attached to: Globally and Write my own content
vbnavbar.css
/* Popup Menus */
.popup_button {
color: #FFFFFF;
text-align: right;
font-weight: bold;
padding: 3px;
margin-top: 3px;
margin-bottom: 3px;
margin-left: 3px;
}
a.popup_button:link,
a.popup_button:visited,
a.popup_button:active,
a.popup_button:hover {
text-decoration: none;
color: #000000;
}
.popup_menu {
position: absolute;
border: 1px solid #000;
background: #ccc;
}
.popup_menu ul
{
margin:0px;
padding:0px;
list-style-type:none;
}
.popup_menu li
{
background: #fff;
margin: 1px;
padding: 0;
}
.popup_menu ul li a
{
display: block;
padding: 3px;
color: #000;
text-decoration: none;
}
* html .popup_menu ul li a {
display: block;
width: 100%;
}
.popup_menu a:hover {
background: #C7DBEE;
text-decoration: none;
color: #000;
}
.menupop {
background: #FFFFFF;
color: #000000;
border: 1px solid #0B198C;
}
/* Navbar Menu */
.tvbnav {
background: #81A2C4;
width: 100%;
margin: auto auto;
border-top: 0px;
border-left: 1px solid #0F5C8E;
border-right: 1px solid #0F5C8E;
border-bottom: 1px solid #0F5C8E;
}
/* Navbar CP and Search */
.tvbnavcp{
background: ;
}
.tvbnavsearch{
background: ;
}
Any corrections are welcome so please let me know if this works or doesn't work for you.
Some screenshots of the code modification in action can be seen below:
Guest view:
Admin view:
Admin/Member CP view:
Admin/Member Search view:
Condition and vbnavbar live samples
Screenshots and links to sites that use this code modification on their forums. Thanks to okitai for his permission to allow us to feature his forum here!
Admin: okitai
Forum URL: http://www.ithelp.co.il/
Comments: okitai has actually extended the functionality of the code modification by adding icons for each item in the navigation menu and customising the sub-menus as well, which you can read about here.
------------------------
CHANGELOG
Jan 7th 2009: Minor corrections to vbnavbar.css and headerinclude (Details in post #19)
March 26th 2009: Minor correction to header (Details in post #50)
April 26th 2009: New functions.php for MyBB 1.4.5 (Details in post #59)
July 1st 2009: New functions.php and class_templates.php uploaded for MyBB 1.4.8. Existing users do not need to change to this new version.
December 10th 2009: New functions.php uploaded for MyBB 1.4.10.
April 22nd 2010: New functions.php uploaded for MyBB 1.4.13.
August 4th 2010: Minor modifications to vbnavbar.css and templates header and header_welcomeblock_member (Details in post #110)
------------------------
Known Bugs
New users using IE7 (and IE6) trying to register on the Forums may experience a Passwords must match error. This is because these versions of the browser are unable to handle two sets of password boxes on the same page: one set from the registration section, and the other from this code modification.
Current known solutions are to:
1. Set up 'send random password instead of allowing users to create their own password
2. Ask new users to type the password into the topright login password box as well.
------------------------
FAQs
Q: Guests can see the 'Private messages' menu option although there is a random {1} and {2} instead of any actual values?
A: Please ensure that you download class_templates.php below and replace this file with the one in your /inc folder (clearer instructions in Step 1) The specific difference between the standard MyBB and the download below can be found in this post.
Q: How can I change the background colour of my logo header to [insert name of colour]?
A: By default, the template edits above sets the default background colour to white, so if you would like to change this (like indigored) to something else, please look for this line
<div class="logo" style="background:#fff url('$theme[imgdir]/logobg.gif');">
in Header Templates/header and change the value of background to the colour you would prefer (hex value)An example can be found here
Q: How can I change the font or text colour of my User CP dropdown menu to [insert name of colour]?
A: The text colour is inherited from the class tcat so to override this, you will need to add a few extra lines to vbnavbar.css. This question came about as a user had a white font against their white background (you can find the original reply here) and the necessary change was as follows:
td.tcat td.menu_row a:link,
td.tcat td.menu_row a:visited,
td.tcat td.menu_row a:hover,
td.tcat td.menu_row a:active{
color: #000000;
}
where the value for color: is the appropriate hex value for the colour (in this instance, black).