Customizing WSS 3.0 with Master Pages
page 12 of 14
by Ameet Phadnis
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 91817/ 170

What can you include in the Master Pages?

In this article I have explained how you can create a basic Master Page. But in fact you can do lot of stuff with this Master Page. On one of my recent projects I had to create a Master Page which had tabs, 3 or 4 navigation menus and they wanted the Search control without the default dropdown for Scope. So, I would like to present some tips on customizing the Master Pages.

Adding menu system to launch external websites: This could have been easy with the local navigation. But they wanted it separate from local navigation as it was already used up. I came up with using the ASP:Menu control provided by ASP.NET 2. If you look closely the Navigation menu SharePoint:ASPMenu control is actually inherited from System.Web.UI.WebControls.Menu.  I used the ASP:Menu control on my SharePoint Master Page. Below are the steps involved in adding your own Navigation menu.

Step1: At the appropriate place add the asp:menu control. The syntax could be as:

Listing 8

<asp:Menu runat="server" id="Menu1" width="100%" DataSourceID="ExternalLinks"  
    StaticSubMenuIndent="10px"  Target="_blank">
 </asp:Menu>

Step 2: Now we need to assign the asp:SiteMapDataSource for the above DataSourceID=Externallinks. The sitemapdatasource can be declared as:

Listing 9

<asp:SiteMapDataSource runat="server" ID="ExternalLinks" ShowStartingNode="False" 
    SiteMapProvider="MyMenuProvider"/> 

Step 3: Now we have defined MyMenuProvider as the SiteMapProvider. But we need to let it know where to get the sitemap file. So, we need to add this in the Web.Config file under the SiteMap->Providers section in Web.Config file.

Listing 10

<add name="MyMenuProvider" 
    type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.3600.0, 
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" siteMapFile="Menu.sitemap"/> 

Javascript: I wrote lot of Javascripts in the current Master Page to do lot of formatting stuff. The main formatting was the look and feel of tabs. The tabs had to be controlled by our Javascripts. I also modified the Search Control completely. By default, the search control was displaying the Search Scope dropdown list box, text to enter search and the magnifying glass image. The client wanted to replace the magnifying image and remove all the items from the dropdownlist box except for the Directory. The following is the Javascript which I wrote on the Master Page to accomplish it.

Below is the Listing to remove the scopes from the dropdown and just list the Directory option.

Listing 11

ddlSelects = document.getElementsByTagName('select');
for (var i = 0; i < ddlSelects.length; i++)
{
  if (ddlSelects(i).title == "Search Scope")
  {
    var count;
    var diroption;
    for (count = 0; count < ddlSelects(i).options.length; count++)
    {
      if (ddlSelects(i).options(count).text == "Directory")
        diroption = ddlSelects(i).options(count);
 
    }
    ddlSelects(i).options.length = 0;
    ddlSelects(i).options.add(diroption);
 
  }
}

This is the listing to change the magnifying icon glass at run time only for this Master Page.

Listing 12

var ahrefs;
ahrefs = document.getElementsByTagName('a');
for (var i = 0; i < ahrefs.length; i++)
{
 
  if (ahrefs(i).title == "Go Search")
  {
    ahrefs(i).innerHTML =
      "<img title=\"Go Search\" 
onmouseover=\"this.src='/_layouts/images/button_go_02.jpg'\" 
onmouseout=\"this.src='/_layouts/images/button_go_01.jpg'\" alt=\"Go Search\" 
src=\"/_layouts/images/button_go_01.jpg\" style=\"border-width:0px;\" />";
    ahrefs(i).href = "javascript:SearchLink();"
  }
}

In short, there are various things you can do to the Master Page. In fact, the stuff you could do on ASP.NET applications master page can also be done on the SharePoint Master Page.


View Entire Article

User Comments

Title: Edward   
Name: Logo Design
Date: 2012-07-06 4:10:56 AM
Comment:
I am impressed by the quality of information on this website. There are a lot of good resources here. I am sure I will visit this place again soon
Title: ExternalLInks display   
Name: Sam
Date: 2010-04-18 12:22:10 PM
Comment:
hey,
I was wasting sometime when i found something which most of us will tend to make mistake on:
http://baigadil.blogspot.com/2010/04/exterbal-links-in-sharepoint-aspmenu.html
Title: Any way to use Cascading Master pages   
Name: Diwakar
Date: 2008-09-05 5:05:33 PM
Comment:
Is there a way to use Cascading Master pages? The scenario i have is - the root site will have the default master page, the sub site should be able to use their own Master page. I don't want to copy all the contents from the default Master Page and copy it into the Sub site's master page and then add the new stuff. Rather i want to leave the common stuff in the default master page and create the Sub Site master page with new stuff only. And when a page from the Sub site is rendered it uses the combination of two master pages.
Is this possible??
Title: And for wss v3?   
Name: Omar Damiani
Date: 2008-05-02 8:56:04 AM
Comment:
But this works only for MOSS 2007, for wss v3 what do you have to do to create/add a new Master Page?

For wss v3 in the Site Settings you don't have "Master Page" voice in the "Look and Feel" menù (as explained in the "Assigning your Master Page to your site" section of this article...)
Title: great article   
Name: klibey
Date: 2008-04-25 11:32:50 AM
Comment:
you mentioned in the part about adding the sitemap provider to the web.config file...
siteMapFile="Menu.sitemap"

this makes sense, the only thing I am wondering is
where would I drop my sitemap file at?

Thanks for the excellent resource,

Klibey
Title: WSS or Moss   
Name: Manuelito
Date: 2007-09-06 7:51:00 AM
Comment:
Hi,
I think it's about master pages for WSS and MOSS (because you show us snapshots of moss publishing sites)

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2019 ASPAlliance.com  |  Page Processed at 2019-09-17 10:54:20 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search