Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > Programming Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
How To Add Additional Links To Your Navbar
peterska2
Join Date: Oct 2003
Posts: 6,504

 

Manchester, UK
Show Printable Version Email this Page Subscription
peterska2 peterska2 is offline 06-17-2006, 10:00 PM

There is one thing that you never seem to have enough of with a modified vBulletin site, and that is navbar space. This article covers how to add additional links to your navbar both on your regular one, and adding another row to it to stop it getting too busy. Also included in this article is showing and hiding links for guests and members.

Part One: Adding Links To Your Standard Navbar

Scenario used: You have a HTML page on your site with a map to the location of a regular meeting place for people from your site. You need to add the link to this page to your navbar for easy access by your visitors. This page is located at yoursite.com/map.html

To add a link to the additional page (it can be a page within vB or not even on your site) you need to use the following code:
Code:
<td class="vbmenu_control"><a href="http://yoursite.com/map.html" target="_blank">Map</a></td>
This code contains 4 important aspects.

Code:
<td class="vbmenu_control">
This tells you how the link will be displayed. Navbar links use the vbmenu_control class as defined in your CSS so they will always be in this format (Note: Some styles use different formats depending on the level of customization that has been carried out).


Code:
<a href="http://yoursite.com/map.html"
This tells us where the link is going to. You can link to a page anywhere on the internet by using this format. If the page you are linking to is in the same directory as your forums then you only need to use the page name, in this case map.html


Code:
target="_blank"
This tells your browser to open the link in a new window. If you want it to open in the same window then you simply miss this code out.


Code:
Map</a></td>
This displays the title of the link that will be displayed and also ends the link code and section in the navbar.


The best place to add the code for your additional link, is either immediately before or after the link to the calendar
Code:
<td class="vbmenu_control"><a href="calendar.php$session[sessionurl_q]">$vbphrase[calendar]</a></td>
Part Two: Creating Another Row In Your Navbar

If you have a number of modifications installed that have required additional links on your navbar, it quickly becomes very full. Now you can install a modification to add another navbar to your site, or you can simply create another row in your existing one.

When adding another row, it is important that you use a new table, otherwise your links will be forced into alignment with those on the top row, leaving an unsightly gap at the right side of the row.

In your navbar template, locate the following code:
Code:
<if condition="$show['member']">
            <td class="vbmenu_control"><a href="login.php?$session[sessionurl]do=logout&amp;logouthash=$bbuserinfo[logouthash]" onclick="return log_out()">$vbphrase[log_out]</a></td>
        </if>
    </tr>
    </table>
and add below
Code:
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="0" border="0" width="100%" align="center" style="border-top-width:0px">
    <tr align="center">
<td class="vbmenu_control"><a href="index.php">Sample Link</a></td>
</tr>
</table>
Now you have set up your extra row, you can start adding links to it.

First remove the Sample link from the code above by deleting that line from the template. Then using the method from Part One, add your new links to this row. You can move links from the top row by cutting and pasting them into the new row.


Part Three: Showing Links To Guests Or Members Only

There are some things that you really don't want guests to know about. After all, what is the point of showing a guest the link to the usercp when all they will get is a no permissions message? So what can you do about it? Wrapping the whole code for the link in an if conditional will only show the link to those who meet the criteria set.

To show a link to members only use:
Code:
<if condition="$show[member]">[high]link code from part one[/high]</if>
This literally means what it says. If you are a member, then show the link.

The same works for guests:
Code:
<if condition="$show[guest]">[high]link code from part one[/high]</if>
Using these two conditions, you can show and hide links to guests and members. Any links that do not use a condition will always show.



I hope that this helps with managing links on your navbar better. Feel free to ask any questions related to this.
Reply With Quote
  #42  
Old 02-08-2009, 01:38 PM
bposner bposner is offline
 
Join Date: Feb 2009
Posts: 150
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Lynne View Post
Do you see a template called 'navbar' under the Navigation /Breadcrumb templates? That is the template you need to modify for the navigation bar. If you have another style, it could be that they don't have the navigation in the navbar template. In that case, you need to figure out which template they put them in. To find the template, do this - vboptions > General Settings > Add Template Name in HTML Comments > set to Yes . Then go back to your page and view the source code and you will see the name of the template called around your part of the code. Sometimes the template is the one mentioned at the very top of the page source.
Thank you so much for your time and patience. I foujnd all I need, and want to simply add a link to the full forum display that is now hidden by a logo. So (not know all the variables in this system) want to take this code below and simple have it display the forum list, or forum home with the user clicks. Rather than just building a link www.mysite.com/forum I'm sure there is a command to display the forum, yes?

Here the simple code:

<if condition="$show['member']">
<td><a href="usercp.php$session[sessionurl_q]">$vbphrase[user_cp]</a></td>
</if>



I guess I just need to know what the $show command would be and where to put the actual displayed link.

Thank you!!!!
Reply With Quote
  #43  
Old 02-08-2009, 02:46 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You don't want to use that condition around the link. You just want a link - try this where you want it:

HTML Code:
<td class="vbmenu_control"><a href="$vboptions[homeurl]?$session[sessionurl]">Home</a></td>
In place of Home, you could put $vboptions[bbtitle] to have your forum title in it's place.
Reply With Quote
  #44  
Old 02-08-2009, 05:12 PM
bposner bposner is offline
 
Join Date: Feb 2009
Posts: 150
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thank you very much.. appreciate the time... It's a learning curve. I use to work on forums many years ago with dial-in BBS Before internet. Same concept, just not use to php.
Thanks a bunch.
Reply With Quote
  #45  
Old 06-22-2009, 02:05 AM
belindazhu belindazhu is offline
 
Join Date: Mar 2009
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by peterska2 View Post
There is one thing that you never seem to have enough of with a modified vBulletin site, and that is navbar space. This article covers how to add additional links to your navbar both on your regular one, and adding another row to it to stop it getting too busy. Also included in this article is showing and hiding links for guests and members.

Part One: Adding Links To Your Standard Navbar

Scenario used: You have a HTML page on your site with a map to the location of a regular meeting place for people from your site. You need to add the link to this page to your navbar for easy access by your visitors. This page is located at yoursite.com/map.html

To add a link to the additional page (it can be a page within vB or not even on your site) you need to use the following code:
Code:
<td class="vbmenu_control"><a href="http://yoursite.com/map.html" target="_blank">Map</a></td>
This code contains 4 important aspects.

Code:
<td class="vbmenu_control">
This tells you how the link will be displayed. Navbar links use the vbmenu_control class as defined in your CSS so they will always be in this format (Note: Some styles use different formats depending on the level of customization that has been carried out).


Code:
<a href="http://yoursite.com/map.html"
This tells us where the link is going to. You can link to a page anywhere on the internet by using this format. If the page you are linking to is in the same directory as your forums then you only need to use the page name, in this case map.html


Code:
target="_blank"
This tells your browser to open the link in a new window. If you want it to open in the same window then you simply miss this code out.


Code:
Map</a></td>
This displays the title of the link that will be displayed and also ends the link code and section in the navbar.


The best place to add the code for your additional link, is either immediately before or after the link to the calendar
Code:
<td class="vbmenu_control"><a href="calendar.php$session[sessionurl_q]">$vbphrase[calendar]</a></td>
Part Two: Creating Another Row In Your Navbar

If you have a number of modifications installed that have required additional links on your navbar, it quickly becomes very full. Now you can install a modification to add another navbar to your site, or you can simply create another row in your existing one.

When adding another row, it is important that you use a new table, otherwise your links will be forced into alignment with those on the top row, leaving an unsightly gap at the right side of the row.

In your navbar template, locate the following code:
Code:
<if condition="$show['member']">
            <td class="vbmenu_control"><a href="login.php?$session[sessionurl]do=logout&amp;logouthash=$bbuserinfo[logouthash]" onclick="return log_out()">$vbphrase[log_out]</a></td>
        </if>
    </tr>
    </table>
and add below
Code:
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="0" border="0" width="100%" align="center" style="border-top-width:0px">
    <tr align="center">
<td class="vbmenu_control"><a href="index.php">Sample Link</a></td>
</tr>
</table>
Now you have set up your extra row, you can start adding links to it.

First remove the Sample link from the code above by deleting that line from the template. Then using the method from Part One, add your new links to this row. You can move links from the top row by cutting and pasting them into the new row.


Part Three: Showing Links To Guests Or Members Only

There are some things that you really don't want guests to know about. After all, what is the point of showing a guest the link to the usercp when all they will get is a no permissions message? So what can you do about it? Wrapping the whole code for the link in an if conditional will only show the link to those who meet the criteria set.

To show a link to members only use:
Code:
<if condition="$show[member]">[high]link code from part one[/high]</if>
This literally means what it says. If you are a member, then show the link.

The same works for guests:
Code:
<if condition="$show[guest]">[high]link code from part one[/high]</if>
Using these two conditions, you can show and hide links to guests and members. Any links that do not use a condition will always show.



I hope that this helps with managing links on your navbar better. Feel free to ask any questions related to this.
thanks, reserved.
Reply With Quote
  #46  
Old 08-14-2009, 04:48 AM
ilrglen's Avatar
ilrglen ilrglen is offline
 
Join Date: Jun 2008
Location: Yorkton, SK
Posts: 70
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Here's an interesting problem. What does a guy do when he apparently hits the character limit when adding links? I have a lot on my site and I've pretty much deleted every tab and comment in my navbar to make more room. Any suggestions?
Reply With Quote
  #47  
Old 10-10-2009, 04:03 PM
Hawk7173 Hawk7173 is offline
 
Join Date: Dec 2004
Posts: 169
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I've used this....

<!-- Navbar Links -->
<div align="center">
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="0" border="0" width="100%" align="center" style="border-top-width:1px">
<tr align = "center" >
<td class="vbmenu_control"><if condition="$show['member']">
<td class="vbmenu_control"><a href="http://m14tfl.com/upload/showthread.php?p=494101#post494101">Advertise</a></td></if>

<td class="vbmenu_control"><if condition="$show['member']">
<td class="vbmenu_control"><a href="http://m14tfl.com/upload/forumdisplay.php?f=168">Please
Visit Our Sponsors Here</a></td></if>

<td class="vbmenu_control"><if condition="$show['member']">
<td class="vbmenu_control"><a href="http://m14tfl.com/upload/showthread.php?t=75674">Make a Donation Here </a></td></if>

</tr>
</table>
</div>
<!-- / Navbar Links -->


And the links in the navbar don't showup centered properly. I tried adding spaces, but this resulted in a line showing to the left of the link where the spaces are when hovering over the link.

I need to be able to set the links in their proper position.

Reply With Quote
  #48  
Old 10-10-2009, 04:40 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Your html is totally incorrect. For every <td>, you need a </td>. And, you don't put <td> inside another <td> which is what you are doing.
Reply With Quote
  #49  
Old 10-10-2009, 05:26 PM
Hawk7173 Hawk7173 is offline
 
Join Date: Dec 2004
Posts: 169
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I changed it to this and it still does the same thing.

<!-- Navbar Links -->
<div align="center">
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="0" border="0" width="100%" align="center" style="border-top-width:1px">
<tr align = "center" >
<if condition="$show['member']">
<td class="vbmenu_control"><a href="http://m14tfl.com/upload/showthread.php?p=494101#post494101">Advertise</a></td></if>

<if condition="$show['member']">
<td class="vbmenu_control"><a href="http://m14tfl.com/upload/forumdisplay.php?f=168">Please
Visit Our Sponsors Here</a></td></if>

<if condition="$show['member']">
<td class="vbmenu_control"><a href="http://m14tfl.com/upload/showthread.php?t=75674">Make a Donation Here</a></td></if>

</tr>
</table>
</div>
<!-- / Navbar Links -->
Reply With Quote
  #50  
Old 10-10-2009, 08:54 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You are never going to get them perfectly centered unless you apply something to set the width of the columns and then center the words in those columns. All three of those links only show to members, so why not have the whole table in the condition and then set the width of each column to 33% and center the text in each column?
Reply With Quote
  #51  
Old 10-10-2009, 09:13 PM
Hawk7173 Hawk7173 is offline
 
Join Date: Dec 2004
Posts: 169
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

sounds like a plan..... I'll have to do some hunting in order to figure out how to do the column widths as I'm fairly new to html. Unless you'd be gracious enough to give me an example?

--------------- Added [DATE]1255215055[/DATE] at [TIME]1255215055[/TIME] ---------------

I figured out how to size the columns. Thank you for your help!!!!
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 09:03 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.10120 seconds
  • Memory Usage 2,348KB
  • Queries Executed 26 (?)
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
  • (20)bbcode_code
  • (1)bbcode_html
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • 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