Many moons ago in SharePoint v2 land we often found ourselves inventing some pretty clever solutions. The problem was they took quite awhile to bring up to production level.
For example: Raise your hand if you remember the “Document Library Navigation” style used in v2, in case you’ve forgotten about this fan favorite of the time, read this blog post I made a year or so ago on the topic. Amanda introduced me to the concept about a year before I seen it used mainstream.
Let’s revisit the v2 document library navigation technique for just a moment. The main idea was you stored your web part pages in a document library, then you added some nifty meta-data which allowed you to create some fairly funky filters which displayed only certain pages in certain views. These represented the navigation. Sure it got the job done but the solution was complex, long and drawn out.
Well, that was then and this is now. Fast forward a year or so and we now have the concept of “Content Types”. I cannot stress how UNDER hyped content types are, in fact in the coming months I’d bet my bottom dollar you’ll see them at the center of alot of the next generation OOTB solutions you crazy cats build.
Lets see how we can leverage the OOTB functinality in WSS v3 to create intelligent navigation menu’s in a couple of clicks … AND make managing them much easier using our friends the content types. In the end we will have a single list to manage the links of as many menus as we wish to build.
There is a visual below every major step in case you get lost…
Creating smart navigation menu’s using content types:
Create a links iist to hold all of the links.
- Select Site Actions, Create
- Select Links List from the Tracking Column
- Name your list “Navigation Links” and click create.
Before you can create content types on a list or library you must first enable them. To do this:
1. Select Settings, List Settings (From the toolbar while on the Allitems.aspx view of your list)
2. Select Advanced Settings
3. Check “Yes” for Allow Management of Content Types
Create a content type for each navigation menu. In this example we will assume a main and sub navigation menu. The important trick here is creating your site content types at the TOP LEVEL of the site collection. That way they’re avaialbel to all sub sites below.
- From the Site Actions menu select Site Settings
- Select Go to Top Level Site Settings
- From Galleries Select Site Content Types
- Click Create, Name this one MainNav, Choose Link Content Type for Parent and Create a New Group called Custom
- Create another content type (by repeating the previous step) this time naming it SubNav
Add the content types we just created to your list. To do this:
1. Go to settings, list settings (from the list’s allitems.aspx view)
2. Locate the content types area and select add from existing site content types
3. Select the Custom Content Types Group
4. Add the main and sub nav content types and click ok
At this point we have created two potential “types” of content which we can create in our list, MainNav and SubNav. Take a look at the items in the drop down for the “New” button on your list now. Should look similar to the screenshot below.
Pretty neat huh? You can see things taking shape. When we want to create a link in our MainNav we select it when creating a new link and vice versa.
Now all we have to do is add the links list to a page and create a view. – Moving right along …
Create Views for Sub and Main Navigation on your list
- From the allitems.aspx view of your list select Settings, List Settings
- Scroll down to Views and select Create View
- Select Standard View
- Name it MainNav
- Remove all columns besides (URL) with edit menu
- Now the magic , Filter where Content Type (is equal to) MainNav
- Click OK
- Repeat the process, this time naming your view SubNav and filtering where Content Type is equal to SubNav
Add the list the page(s) you wish to have the menu(s) on:
- From your home page select Site Actions, Edit Page
- Select Add Web Parts
- Add your Navigation Links List in a web part zone (add it twice)
- You can select exit edit mode from the top right
Set your web part titles and default views via Modify Shared Web Part
- Select the DOWN ARROW on the right of your web part title, select Modfiy Shared Web Part
- From the toolpane now visable on the right, select MainNav from the Selected View drop down (at the top)
- From Toolbar select No Toolbar
- Next select appearance, in the Title field give it the name Main Navigation
- Select OK
- Repeat this process for the other web part directly below, naming it Sub Navigation and setting the View to SubNav
That’s it, you are all set up. You can now add a link to your Navigation Links List and Select what navigation menu you want it to show up in. Give it a try! Pretty neat huh?