Sunday, October 23, 2011

SharePoint Site Template custom Navigation

Ok this should be simple. It should be straight forward. I should have known better.

Scenario: I'm building a SharePoint 2010 web template.
What I want to do: I want to display two links in the top nav (Home & Shared Documents). I want this navigation to be available as soon as the Site collection is created. There's an obvious place in the onet.xml file to place this. But this area is poorly documented. I had to do a bit of trial and error to achieve what I wanted.

This is the solution to my problem but I have spent way too much time to achieve something so simple.

<NavBars>
 <NavBar Name="$Resources:core,nav_Home;" Separator="&amp;nbsp;&amp;nbsp;&amp;nbsp;" Body="&lt;a ID='onettopnavbar#LABEL_ID#' href='#URL#' accesskey='J'&gt;#LABEL#&lt;/a&gt;" ID="1002" />
 <NavBar Name="SharePoint Top Navbar" ID="1002">
  <NavBarLink Name="Shared Documents" Url="Shared%20Documents/">
  </NavBarLink>
 </NavBar>
</NavBars>

"SharePoint Top Navbar" is the top navigation nav bar. If you want to add links to the top navigation you need to add them in this node.

No comments:

Post a Comment