2/22/2009

SharePoint: Annotated Minimal Master Page

Yet another minimal master page!

There are a number of “minimal master pages” on the web:

I created this one for my SharePoint Designer class to both highlight the sections (the <h3> tags) and to document optional vs. required sections.

 

You can download this file from here.

<!-- Optional DOCTYPE -->
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>

<!-- Tags needed by SharePoint and ASP.Net -->
<%@Master language="C#"%>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="wssuc" TagName="Welcome" src="~/_controltemplates/Welcome.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="DesignModeConsole" src="~/_controltemplates/DesignModeConsole.ascx" %>

<!-- Standard HTML tag with optional text direction "dir=" (Left to Right vs Right to Left for multilingual sites - More info: http://www.w3.org/TR/REC-html40/struct/dirlang.html#h-8.2 -->
<HTML dir="<%$Resources:wss,multipages_direction_dir_value%>" runat="server" xmlns:o="urn:schemas-microsoft-com:office:office" __expr-val-dir="ltr">

<HEAD runat="server">

        <!-- common meta tags - optional, but you should at least keep the "Expires" to control browser caching -->
    <META Name="GENERATOR" Content="Microsoft SharePoint">
    <META Name="progid" Content="SharePoint.WebPartPage.Document">
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
    <META HTTP-EQUIV="Expires" content="0">

    <!-- optional - generates this: <META NAME="ROBOTS" CONTENT="NOHTMLINDEX"/> based on options set in Site Actions, Site Settings, Search Visibility -->
    <SharePoint:RobotsMetaTag runat="server"/>

        <!-- Page title as supplied from the content page's ASP:Content tag -->       
    <Title ID=onetidTitle>
        <asp:ContentPlaceHolder id=PlaceHolderPageTitle runat="server"/>
    </Title>

        <!-- these two tags are found in non-publishing sites and load the CSS in the expected order -->
            <!-- this loads CORE.CSS and is not need if you are creating your own CSS -->
            <Sharepoint:CssLink runat="server"/>
            <!-- this loads the theme select by the user in Site Settings and is not need if you are creating your own CSS -->
            <SharePoint:Theme runat="server"/>
            <!-- your CSS links can go here -->
            <!-- <link rel="stylesheet" type="text/css" href="yourstylesheet" /> -->
        <!-- A publishing master page uses both Sharepoint.CssLink and SsharePoint:CssRegistration controls
            to load style sheets.
          Note: The CssLink control will render all of the CssRegistration CSS files in alphabetical order (!)
                and then follow with CORE.CSS - This might not be what you expected!   
        -->

    <!-- Renders a link to a JavaScript library used by SharePoint -->
    <SharePoint:ScriptLink language="javascript" name="core.js" Defer="true" runat="server"/>
    <!-- Renders a link to a custom JavaScript URL defined in onet.xml (if present) -->
    <SharePoint:CustomJSUrl runat="server"/>
    <!-- optional - Renders path to .disco file for clients like VS2005 to discover web services on the server -->
    <SharePoint:SoapDiscoveryLink runat="server"/>
    <!-- this lets content pages load additional style sheets, javascript, meta tags etc -->
    <asp:ContentPlaceHolder id="PlaceHolderAdditionalPageHead" runat="server">
    </asp:ContentPlaceHolder>

    <!-- optional this lets installed "Features" load additional style sheets, javascript, meta tags etc -->
    <SharePoint:DelegateControl runat="server" ControlId="AdditionalPageHead" AllowMultipleControls="true"/>

</HEAD>

<!-- the onload runs javascript needed for master pages - scroll is optional -->
<BODY scroll="yes" onload="javascript:if (typeof(_spBodyOnLoadWrapper) != 'undefined') _spBodyOnLoadWrapper();">

    <!-- form required for all ASPX pages -->
    <form runat="server" onsubmit="return _spFormOnSubmitWrapper();">

        <!-- required to support web parts -->
        <WebPartPages:SPWebPartManager id="m" runat="Server"/>

<h3>Typical top of page items</h3>
        <asp:ContentPlaceHolder id="PlaceHolderGlobalNavigation" runat="server">
        <!-- common controls for the top of a site -->
            <!-- global breadcrumb trail -->
            <asp:ContentPlaceHolder id="PlaceHolderGlobalNavigationSiteMap" runat="server">
                <asp:SiteMapPath SiteMapProvider="SPSiteMapProvider" id="GlobalNavigationSiteMap" RenderCurrentNodeAsLink="true" SkipLinkText="" NodeStyle-CssClass="ms-sitemapdirectional" runat="server"/>
            </asp:ContentPlaceHolder>
            <!-- optional - renders the variations link -->
            <SharePoint:DelegateControl runat="server" ControlId="GlobalSiteLink0"/>
            <!-- optional - renders the MySite link -->
            <SharePoint:DelegateControl ControlId="GlobalSiteLink1" Scope="Farm" runat="server"/>
            <!-- optional - renders the MyLinks menu -->
            <SharePoint:DelegateControl ControlId="GlobalSiteLink2" Scope="Farm" runat="server"/>
            <!-- optional - renders the Welcome menu -->
            <wssuc:Welcome id="explitLogout" runat="server"/>
            <!-- optional help button -->
            <a href="javascript:TopHelpButtonClick('NavBarHelpHome')" AccessKey="<%$Resources:wss,multipages_helplink_accesskey%>" id="TopHelpLink" title="<%$Resources:wss,multipages_helplinkalt_text%>" runat="server">
            <img align='absmiddle' border=0 src="/_layouts/images/helpicon.gif" alt="<%$Resources:wss,multipages_helplinkalt_text%>" runat="server">
            </a>
        &nbsp;&nbsp;&nbsp;&nbsp;</asp:ContentPlaceHolder>

<hr>
<h3>Typical top of page site / page header items - Site Logo, Title etc.</h3>

        <!-- Typical Site Header items - Title, Logo, etc -->

        <!-- optional - site logo from Site Settings -->
        <SharePoint:SiteLogoImage id="onetidHeadbnnr0" LogoImageUrl="/_layouts/images/titlegraphic.gif" runat="server"/>

        <!-- site title from site settings - place holder is required, SPLinkButton and ProjectProperty are optional  -->   
        <asp:ContentPlaceHolder id="PlaceHolderSiteName" runat="server">
            <SharePoint:SPLinkButton runat="server" NavigateUrl="~site/" id="onetidProjectPropertyTitle">
                <SharePoint:ProjectProperty Property="Title" runat="server" />
            </SharePoint:SPLinkButton>
        </asp:ContentPlaceHolder>

<hr>
<h3>Search controls</h3>

        <!-- Search controls - placeholder is required -->
        <asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server">
            <!-- optional - default content for search - actual search depends on content page and / or Site Settings, Search Settings (to turn on advanced search)-->
            <SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox"/>
        </asp:ContentPlaceHolder>

<!-- ------------------------------------------   -->

    <!-- required placeholder - this typically wraps the entire top navigation -->
    <asp:ContentPlaceHolder id="PlaceHolderTopNavBar" runat="server">

<hr>
<h3>Typical tab navigation</h3>

        <!-- Tab bar -->
        <!-- required placeholder -->
        <asp:ContentPlaceHolder id="PlaceHolderHorizontalNav" runat="server">

            <!-- ASP.Menu based SharePoint menu - lots of customization possibilities here -->
            <SharePoint:AspMenu
              ID="TopNavigationMenu"
              Runat="server"
              DataSourceID="topSiteMap"
              EnableViewState="false"
              AccessKey="<%$Resources:wss,navigation_accesskey%>"
              Orientation="Horizontal"
              StaticDisplayLevels="2"
              MaximumDynamicDisplayLevels="1"
              DynamicHorizontalOffset="0"
              StaticPopoutImageUrl="/_layouts/images/menudark.gif"
              StaticPopoutImageTextFormatString=""
              DynamicHoverStyle-BackColor="#CBE3F0"
              SkipLinkText=""
              StaticSubMenuIndent="0"
              CssClass="ms-topNavContainer">
                <StaticMenuStyle/>
                <StaticMenuItemStyle CssClass="ms-topnav" ItemSpacing="0px"/>
                <StaticSelectedStyle CssClass="ms-topnavselected" />
                <StaticHoverStyle CssClass="ms-topNavHover" />
                <DynamicMenuStyle  BackColor="#F2F3F4" BorderColor="#A7B4CE" BorderWidth="1px"/>
                <DynamicMenuItemStyle CssClass="ms-topNavFlyOuts"/>
                <DynamicHoverStyle CssClass="ms-topNavFlyOutsHover"/>
                <DynamicSelectedStyle CssClass="ms-topNavFlyOutsSelected"/>
            </SharePoint:AspMenu>
            <SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource">
                <Template_Controls>
                    <asp:SiteMapDataSource
                      ShowStartingNode="False"
                      SiteMapProvider="SPNavigationProvider"
                      id="topSiteMap"
                      runat="server"
                      StartingNodeUrl="sid:1002"/>
                </Template_Controls>
            </SharePoint:DelegateControl>
        </asp:ContentPlaceHolder>
<hr>

<h3>Site actions menu</h3>

        <!-- optional - Site Actions Menu -->
        <SharePoint:SiteActions runat="server" AccessKey="<%$Resources:wss,tb_SiteActions_AK%>" id="SiteActionsMenuMain"
            PrefixHtml="&lt;div&gt;&lt;div&gt;"
            SuffixHtml="&lt;/div&gt;&lt;/div&gt;"
            MenuNotVisibleHtml="&amp;nbsp;">
            <CustomTemplate>
            <SharePoint:FeatureMenuTemplate runat="server"
                FeatureScope="Site"
                Location="Microsoft.SharePoint.StandardMenu"
                GroupId="SiteActions"
                UseShortId="true"
                >
                <SharePoint:MenuItemTemplate runat="server" id="MenuItem_Create"
                    Text="<%$Resources:wss,viewlsts_pagetitle_create%>"
                    Description="<%$Resources:wss,siteactions_createdescription%>"
                    ImageUrl="/_layouts/images/Actionscreate.gif"
                    MenuGroupId="100"
                    Sequence="100"
                    UseShortId="true"
                    ClientOnClickNavigateUrl="~site/_layouts/create.aspx"
                    PermissionsString="ManageLists, ManageSubwebs"
                    PermissionMode="Any" />
                <SharePoint:MenuItemTemplate runat="server" id="MenuItem_EditPage"
                    Text="<%$Resources:wss,siteactions_editpage%>"
                    Description="<%$Resources:wss,siteactions_editpagedescription%>"
                    ImageUrl="/_layouts/images/ActionsEditPage.gif"
                    MenuGroupId="100"
                    Sequence="200"
                    ClientOnClickNavigateUrl="javascript:MSOLayout_ChangeLayoutMode(false);"
                    />
                <SharePoint:MenuItemTemplate runat="server" id="MenuItem_Settings"
                    Text="<%$Resources:wss,settings_pagetitle%>"
                    Description="<%$Resources:wss,siteactions_sitesettingsdescription%>"
                    ImageUrl="/_layouts/images/ActionsSettings.gif"
                    MenuGroupId="100"
                    Sequence="300"
                    UseShortId="true"
                    ClientOnClickNavigateUrl="~site/_layouts/settings.aspx"
                    PermissionsString="EnumeratePermissions,ManageWeb,ManageSubwebs,AddAndCustomizePages,ApplyThemeAndBorder,ManageAlerts,ManageLists,ViewUsageData"
                    PermissionMode="Any" />
            </SharePoint:FeatureMenuTemplate>
            </CustomTemplate>
        </SharePoint:SiteActions>

        </asp:ContentPlaceHolder>

<hr>
<h3>Edit Consoles - Edit page, etc...</h3>

    <!-- Edit Page -->
    <asp:ContentPlaceHolder ID="WSSDesignConsole" runat="server">
        <wssuc:DesignModeConsole id="IdDesignModeConsole" runat="server"/>
    </asp:ContentPlaceHolder>
    <!-- Publishing site console -->
    <asp:ContentPlaceHolder ID="SPNavigation" runat="server">
        <SharePoint:DelegateControl runat="server" ControlId="PublishingConsole"
           PrefixHtml="&lt;tr&gt;&lt;td colspan=&quot;4&quot; id=&quot;mpdmconsole&quot; class=&quot;ms-consolemptablerow&quot;&gt;"
           SuffixHtml="&lt;/td&gt;&lt;/tr&gt;">
        </SharePoint:DelegateControl>
    </asp:ContentPlaceHolder>

<hr>
<h3>Typical Page Header</h3>

    <!-- Page Image -->
    <asp:ContentPlaceHolder id="PlaceHolderPageImage" runat="server"/>

    <!-- Breadcrumb trail for sub pages -->
    <asp:ContentPlaceHolder id="PlaceHolderTitleBreadcrumb" runat="server">
        <asp:SiteMapPath SiteMapProvider="SPContentMapProvider" id="ContentMap" SkipLinkText="" NodeStyle-CssClass="ms-sitemapdirectional" runat="server"/> &nbsp;
    </asp:ContentPlaceHolder>
    <!-- Page Title -->
    <asp:ContentPlaceHolder id="PlaceHolderPageTitleInTitleArea" runat="server" />
    <!-- Mini Console  -->
    <asp:ContentPlaceHolder id="PlaceHolderMiniConsole" runat="server"/>

<hr>
<h3>Typical Left Navigation</h3>

    <!-- Left navigation data source -->
    <asp:ContentPlaceHolder id="PlaceHolderLeftNavBarDataSource" runat="server" />
    <!-- Calendar date picker area - used by calendar views -->
    <asp:ContentPlaceHolder id="PlaceHolderCalendarNavigator" runat="server" />
    <!-- Quick Launch area including View All Site Content and Recycle bin -->
    <asp:ContentPlaceHolder id="PlaceHolderLeftNavBar" runat="server">

        <!-- View All Site Content -->
        <Sharepoint:SPSecurityTrimmedControl runat="server" PermissionsString="ViewFormPages">
            <SharePoint:SPLinkButton id="idNavLinkViewAll" runat="server" NavigateUrl="~site/_layouts/viewlsts.aspx" Text="<%$Resources:wss,quiklnch_allcontent%>" AccessKey="<%$Resources:wss,quiklnch_allcontent_AK%>"/>
        </SharePoint:SPSecurityTrimmedControl>
        <!-- Quick Launch menu -->
        <Sharepoint:SPNavigationManager
            id="QuickLaunchNavigationManager"
            runat="server"
            QuickLaunchControlId="QuickLaunchMenu"
            ContainedControl="QuickLaunch"
            EnableViewState="false">
            <SharePoint:DelegateControl runat="server" ControlId="QuickLaunchDataSource">
                <Template_Controls>
                <asp:SiteMapDataSource SiteMapProvider="SPNavigationProvider" ShowStartingNode="False" id="QuickLaunchSiteMap" StartingNodeUrl="sid:1025" runat="server" />
             </Template_Controls>
            </SharePoint:DelegateControl>
            <SharePoint:AspMenu id="QuickLaunchMenu" DataSourceId="QuickLaunchSiteMap" runat="server" Orientation="Vertical" StaticDisplayLevels="2" ItemWrap="true" MaximumDynamicDisplayLevels="0" StaticSubMenuIndent="0" SkipLinkText="">
                <LevelMenuItemStyles>
                    <asp:menuitemstyle CssClass="ms-navheader" />
                    <asp:menuitemstyle CssClass="ms-navitem" />
                </LevelMenuItemStyles>
                <LevelSubMenuStyles>
                    <asp:submenustyle CssClass="ms-navSubMenu1" />
                    <asp:submenustyle CssClass="ms-navSubMenu2" />
                </LevelSubMenuStyles>
                <LevelSelectedStyles>
                    <asp:menuitemstyle CssClass="ms-selectednavheader" />
                    <asp:menuitemstyle CssClass="ms-selectednav" />
                </LevelSelectedStyles>
            </SharePoint:AspMenu>
        </Sharepoint:SPNavigationManager>
        <!--- Tree View - display controled in Site Settings, Tree view --->   
        <Sharepoint:SPNavigationManager
            id="TreeViewNavigationManager"
            runat="server"
            ContainedControl="TreeView">
            <SharePoint:SPLinkButton runat="server" NavigateUrl="~site/_layouts/viewlsts.aspx" id="idNavLinkSiteHierarchy" Text="<%$Resources:wss,treeview_header%>" AccessKey="<%$Resources:wss,quiklnch_allcontent_AK%>"/>
            <SharePoint:SPHierarchyDataSourceControl
             runat="server"
             id="TreeViewDataSource"
             RootContextObject="Web"
             IncludeDiscussionFolders="true"
            />
            <SharePoint:SPRememberScroll runat="server" id="TreeViewRememberScroll" onscroll="javascript:_spRecordScrollPositions(this);" Style="overflow: auto;height: 400px;width: 150px; ">
            <Sharepoint:SPTreeView
                id="WebTreeView"
                runat="server"
                ShowLines="false"
                DataSourceId="TreeViewDataSource"
                ExpandDepth="0"
                SelectedNodeStyle-CssClass="ms-tvselected"
                NodeStyle-CssClass="ms-navitem"
                NodeStyle-HorizontalPadding="2"
                SkipLinkText=""
                NodeIndent="12"
                ExpandImageUrl="/_layouts/images/tvplus.gif"
                CollapseImageUrl="/_layouts/images/tvminus.gif"
                NoExpandImageUrl="/_layouts/images/tvblank.gif"
            >
            </Sharepoint:SPTreeView>
            </Sharepoint:SPRememberScroll>
        </Sharepoint:SPNavigationManager>
        <!-- Recycle Bin -->
        <SharePoint:SPLinkButton runat="server" NavigateUrl="~site/_layouts/recyclebin.aspx" id="idNavLinkRecycleBin" ImageUrl="/_layouts/images/recycbin.gif" Text="<%$Resources:wss,StsDefault_RecycleBin%>" PermissionsString="DeleteListItems"/>

    </asp:ContentPlaceHolder>

<hr>
<h3>Left Actions Area (used by wikis)</h3>

<!-- Left Actions area placeholder - used by Wikis-->
<asp:ContentPlaceHolder id="PlaceHolderLeftActions" runat="server"/>

<hr>
<h3>Page Content</h3>

    <!-- This div wraps the content area and is used by SharePoint to
    display the web part editor panel to the right of the web part zones -->

    <div id="MSO_ContentDiv" runat="server">
        <A name="mainContent"></A>
        <!-- Page Description -->
        <asp:ContentPlaceHolder id="PlaceHolderPageDescription" runat="server"/>
        <!-- Main content area -->
        <asp:ContentPlaceHolder id="PlaceHolderMain" runat="server">
        </asp:ContentPlaceHolder>
    </div>

<hr>
<h3>Form Digest Security Control (not visible)</h3>
<!-- Form Digest Security Control -->
<asp:ContentPlaceHolder id="PlaceHolderFormDigest" runat="server">
    <SharePoint:FormDigest runat=server/>
</asp:ContentPlaceHolder>

<input type="text" name="__spDummyText1" style="display:none;" size=1/>
<input type="text" name="__spDummyText2" style="display:none;" size=1/>
</form>

<hr>
<h3>Other required placeholders not generally needed by a custom master page</h3>

<!-- Footer -->
<asp:ContentPlaceHolder id="PlaceHolderUtilityContent" runat="server"/>
<!-- Used to add body styles to the page header -->
<asp:ContentPlaceHolder id="PlaceHolderBodyAreaClass" runat="server"/>
<!-- Used to add styles to the page header -->
<asp:ContentPlaceHolder id="PlaceHolderTitleAreaClass" runat="server"/>

    <asp:Panel visible="false" runat="server">
    <!-- PLACE UNUSED CONTENT PLACEHOLDERS HERE -->
    <!--- --- Placeholders used in default.master that you will likely not use --- --->
    <!-- Area between page image and page title -->
    <asp:ContentPlaceHolder id="PlaceHolderTitleLeftBorder" runat="server"/>
    <!-- Area between page name and right page border -->
    <asp:ContentPlaceHolder id="PlaceHolderTitleRightMargin" runat="server"/>
    <!-- Area between top nav bar and page content -->
    <asp:ContentPlaceHolder id="PlaceHolderTitleAreaSeparator" runat="server"/>
    <!-- Area above left nav bar -->
    <asp:ContentPlaceHolder id="PlaceHolderLeftNavBarTop" runat="server"/>
    <!-- Sets a width of the left nav bar -->
    <asp:ContentPlaceHolder id="PlaceHolderNavSpacer" runat="server"><IMG SRC="/_layouts/images/blank.gif" width=138 height=1 alt=""></asp:ContentPlaceholder>
    <!-- Area between left nav bar and page content -->
    <asp:ContentPlaceHolder id="PlaceHolderLeftNavBarBorder" runat="server"></asp:ContentPlaceHolder>
    <!-- Area between left nav and content -->
    <asp:ContentPlaceHolder id="PlaceHolderBodyLeftBorder" runat="server"/>
    <!-- Area between content and right page border -->
    <asp:ContentPlaceHolder id="PlaceHolderBodyRightMargin" runat="server"/>
    </asp:Panel>

</BODY>
</HTML>

3 comments:

Hector Insua said...

Great Work Mike! i publish a link in my Spanish SharePoint Blog http://hinsua.blogspot.com/2009/03/minimal-masterpage-comentada.html Thanks!!!

Christian Lobo said...

DEAR GOODNESS!

THANK YOU SO MUCH!!!

YOU = MSDN.

Syed Atif Imtiaz said...

Excellent work.

Note to spammers!

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.