Overview

Ever want to have an easier way to have a global navigation that spans across site collections? SharePoint provides a solution for global navigation within a site collection and it works well. But when you architect SharePoint to have multiple web apps and site collections you do not have any easy solution to create a global navigation system to span those repositories. You would have to recreate your global navigation on each site collection. And any changes to the global navigation would mean that you would have to go to each site collection to make the change…ouch!!! There has got to be a better solution.

Thanks to Marc Anderson and Michael Greene who have created solutions that inspired me to explore solving this problem. Marc Anderson created SPServices, which is a jQuery library for SharePoint Web Services. I am beginning to understand the power of his solution. Then Michael Greene created a solution, Application Wide Quick Launch Control, where you can change or append the Quick Launch on SharePoint sites. Michael’s solution used Marc’s SPServices and jQuery.

Based on what these two have done, I then looked into how we could apply this to the Top Navigation found in SharePoint.

My goal was to do the following:

Be able to add a tab at the beginning or end of the Top Navigation bar.

Create a pull down to maximize space.

Ever see a top nav bar with too many tabs, ouch.

Pull down items are pulled from a standard SP Links list.

Imagine being able to add an item to a list and it is then apart of the top navigation across site collections, yes!

WSS does not give us the ability to have a pull down, lets change that.

Ability to order and group pull down items.

Organization is critical to ease of use.

Grouping Headers can be links or not.

Navigation tab and pull down changes with site theme.

Tabs can be links or not.

What is the end product going to look like, well, something like this. Where we have added a tab called “Services” with a pull down that is grouped. This is a WSS site, where this is not possible out of the box.

And we are pulling this from a list. Take a look at the TopNav links list below. You can see the grouping and ordering is working as well.

Now lets walk through what we have to do to get the above results.

Components needed:

SharePoint Resource Site

SPServices by Marc Anderson

jQuery

SharePoint Designer to edit Master Pages

SharePoint Links List

Solution Code

1) SharePoint Resource Site

I recommend that if you do not already have a site collection devoted to scripts and lists that will be accessible by all, that you create one. This site collection will allow you to have document library where you can house your scripts like jQuery and SPServices. It will also allow you to create lists as needed for example the one we will create to manage the pull down items in our tab.

We need to download the SPServices file that Marc Anderson has put together. You can find it here: http://spservices.codeplex.com/ This file will be used by the script for this solution, so this will need to be added to the document library where you keep scripts. In my case it would go into the document library in my Resources site collection.

Recommendation is to change the name of the file name so that it does not have a version number and should look like this, “jquery.SPServices-latest.min.js”. This will allow you to update in the future to Marc’s latest version without having to go back to each master page and change to the new version name.

3) jQuery

There are two ways to work with a jQuery file. You have a choice of downloading the latest version and putting it in scripts document library or you can point to Google's version which will always be the latest version. This is a choice that you will make. You can download jQuery from here: http://jquery.com/

I would then add this script to me document library in my Resources site collection.

4) SharePoint Designer to edit Master Pages

You will need to have access to SharePoint Designer and be able to edit the Master Pages on the sites you want the global navigation tab to show up on. When you edit a master page you will want to add the following code between the <header></header> tags as diagramed below.

Here is the code you will need to add to each master page. Make sure that the URL’s point to where you have the files housed. They do need to be absolute URL’s, as you will be adding this code across site collections, web apps and even servers.

For example if I put “jquery-latest.js”, “jquery.SPServices-latest.min.js”, and “topnavigation.js” in my Resoures site collection in the document library called ScriptsLibrary, then it would look like this:

Now to create the ease of updating and managing the content in the pull down for the tab, we will need to have a list where the solution can pull the links from. But we also need to create some organization and groupings. So will will create a links list and add some additional columns.

In my Resources site collection I will create a list called TopNav, you are free to name it what you like. This TopNav list will be a Links list. Once created we need to add a couple of other columns:

Group – This column will be used to group the links together. So all “Help” links will be together and all “Features” links will be together.

This is a text field or it can be a choice field if you know all the groups.

LinkType – This column will be used to identify what type of link it is.

This is a Choice column.

We have three choice types and each will cause the pull down to display the link in different way:

Link – This will display the item as a link within the group.

Header – This will display the item as a header without a link.

Header Link – This will display the item as a header with a link.

(Header and Header Link look them same, but act differently)

Next you will want to change the default All Links view to the following:

Sort – Change the following:

All users to order items in this view, set to “No”.

Sort by “LinkType” in “ascending order”.

And Sort by “URL” in “ascending order”.

Group By – Change the following:

Group by to “Group” in “ascending order”.

Show grouping as “Expanded”.

This new view will be the way the items show in the pull down for the global navigation. So you can play with the view here to sort and group it as you wish.

Here is an example of what it should look like once you have several links listed.

Almost there……yeah.

6) Solution Code

Ok, now for the code that will make this all work together. There is a file called topnavigation.js that we will need to be created and edited to make it work in your environment.

In my case it would go into the document library in my Resources site collection.

To make this script work you will need to provide several pieces of data which are listed out below.

[tabSide] - Specify either 'append' or 'prepend'. This will indicated if the new tab will go before or after the default tabs.

Tab front Example: 'prepend'

Tab End Example: 'append'

[titleTabName] - Specify a name for the tab, this will be displayed in the tab.

Tab Name Example: 'Intranet'

[urlTab] - Specify a link only if you want the tab to be clickable, otherwise leave blank with two quotes, ''.

$(document).ready(function(){/*Extended Tabs by Peter AllenVersion 1.0 5/3/2010Purpose: Add a tabs to the beginning (prepend) or end (append) of the default SharePoint Top Navigation tabs.Script Setup: To make this script work you will need to provide several pieces of data which are listed out below.

[tabSide] - Specify either 'append' or 'prepend'. This will indicated if the new tab will go before or after the default tabs. Tab front Example: 'prepend' Tab End Example: 'append'[titleTabName] - Specify a name for the tab, this be displayed in the tab. Tab Name Example: 'Intranet'[urlTab] - Specify a link only if you want the tab to be clickable, otherwise leave blank with with two quotes, ''. Link Example: 'http://www.google.com' No Link Example: ''[listName] - Specify the name of the list for the pull down. List Name Example: 'Links'[listSiteUrl] - Specify the url of the site where the list is located. URL needs to be of the site location NOT of the list location. Incorrect Example: 'http://www.intranet.com/SiteName/List/ListName/' Correct Example: 'http://www.intranet.com/SiteName/'

All above variables will then be constructed as follows, make sure that each field has a ' at the begining and end of each.

Construct: extendedTabs('[tabSide]','[titleTabName]','[urlTab]','[listName]','[listSiteURL]')Example: extendedTabs('append','Projects','http://www.sites.com/Projects/','Projects','http://www.site.com/Resources/');This example adds a tab called Projects at the end, tab links to the Project site, the list for the pull down is called Projects and the list resides in the Resources site.