Wednesday, February 16, 2011

Adding Top Link bar to SharePoint Basic Search Center Template

The Basic Search Center template in SP Foundation 2010 uses the minimal.master master page rather than the v4.master.  The search center template actually requires some additional content placeholders that the v4.master does not support.  I recently needed to add the Top link navigation to this template and decided to add the lines to the minimal.master to achieve this functionality.  Editing the master page allowed the change to persist to the results.aspx page as well which was the desired functionality.  To make the change, open the minimal.master page using SP Designer 2010 and find the following lines:

 <h3 class="s4-mini-header">
    <asp:ContentPlaceHolder id="PlaceHolderPageSubTitle" runat="server" />
   </h3>
  </div>
 </div>

The last line should be around line 118.  After the closing div tag add the following (Do not replace, just add):

<div id="s4-topheader2" class="s4-pr s4-notdlg">
     <a name="startNavigation"></a>
     <div class="s4-rp s4-app">
     </div>
     <div class="s4-lp s4-toplinks">
      <asp:ContentPlaceHolder id="PlaceHolderTopNavBar" runat="server">
        <asp:ContentPlaceHolder id="PlaceHolderHorizontalNav" runat="server">
 <SharePoint:AspMenu
   ID="TopNavigationMenuV4"
   Runat="server"
   EnableViewState="false"
   DataSourceID="topSiteMap"
   AccessKey="<%$Resources:wss,navigation_accesskey%>"
   UseSimpleRendering="true"
   UseSeparateCss="false"
   Orientation="Horizontal"
   StaticDisplayLevels="2"
   MaximumDynamicDisplayLevels="1"
   SkipLinkText=""
   CssClass="s4-tn"/>
 <SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource" Id="topNavigationDelegate">
  <Template_Controls>
   <asp:SiteMapDataSource
     ShowStartingNode="False"
     SiteMapProvider="SPNavigationProvider"
     id="topSiteMap"
     runat="server"
     StartingNodeUrl="sid:1002"/>
  </Template_Controls>
 </SharePoint:DelegateControl>
        </asp:ContentPlaceHolder>
      </asp:ContentPlaceHolder>
     </div>
    </div>

Monday, January 10, 2011

Customizing SharePoint 2010 Tree View Navigation

In Site Settings->Tree View, you can check "Enable Tree View" and you have this nice control that gives you all sorts of drill down links to sites and content within them.  Here is an example of three projects that I have listed under my Projects site and what the default view is:


But what if you want to customize what is displayed and what isn't. In order to modify this, you have to change the master page and find the SPHierarchyDataSourceControl node.  There are some options that you can choose from documented here: http://msdn.microsoft.com/en-us/library/ms439089.aspx


   IncludeDiscussionFolders="false" 
   ShowDocLibChildren="false"
   ShowFolderChildren="false"
   ShowListChildren="false"


You can even change the title of what is displayed here.  I chose to change the title to Current Projects.
Since the SPHierarchyDataSourceControl also has a "RootWebId" member that can be changed, I can move all archived projects to a new location and create another tree control that pulls from that root.  This will give me the ability to display Current and Archived Projects to users.