MOSS母版页制作学习笔记(一)

母版页制作其实应该算是一个比较基础的工作,但是熟练制作出灵活、完整的母版页的人却很少。。为什么会这样呢,分析原因有几个,主要的问题应该是母版页制作是介于开发和美工之间的工作,开发人员关注代码,美工关注界面效果,就忽略和回避了这部分,都不愿意作怎么办,那就我来作吧。。­

­

­

­

首先MOSS的母版页也是来自于asp.net的母版页,原理都是一样的。­

­

基于微软提供的文档,母版页制作有两种方式:一,布局变化不大的情况下,在原母版页上修改;二,重新制作。­

­

­

­

我们主要说说重新制作吧。。­

­

­

­

最简单的理解就是:­

­

第一,先知道哪些是母板页中必须有的元素;­

­

第二,从美工处拿到界面的展示效果和html布局,css样式表;­

­

第三,从SPD创建一个新的母版页,将html代码复制进去;­

­

第四,将css放到相应位置,母版页应用对应的css;­

­

第五,将美工模拟的控件用母版页中的占位符替换;­

­

第六,除了必须的元素外,还需要添加什么附加控件,也加到相应的位置;­

­

完成!­

­

­

­

下面详细说下每一步:­

­

一、哪些是母板页中必须有的元素­

­

­

­

空白的,没有样式的包括所有占位符的母版页:­

­

­

­

<%-- Identifies this page as a .master page written in C# and registers tag prefixes, namespaces, assemblies, and controls. --%>­

<%@ Master language="C#" %>­

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">­

<%@ Import Namespace="Microsoft.SharePoint" %>­

<%@ Register Tagprefix="SPSWC" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>­

<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>­

<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>­

<%@ Register Tagprefix="PublishingWebControls" Namespace="Microsoft.SharePoint.Publishing.WebControls" Assembly="Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>­

<%@ Register Tagprefix="PublishingNavigation" Namespace="Microsoft.SharePoint.Publishing.Navigation" Assembly="Microsoft.SharePoint.Publishing, 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" %>­

<%@ Register TagPrefix="PublishingVariations" TagName="VariationsLabelMenu" src="~/_controltemplates/VariationsLabelMenu.ascx" %>­

<%@ Register Tagprefix="PublishingConsole" TagName="Console" src="~/_controltemplates/PublishingConsole.ascx" %>­

<%@ Register TagPrefix="PublishingSiteAction" TagName="SiteActionMenu" src="~/_controltemplates/PublishingActionMenu.ascx" %>­

<%-- Uses the Microsoft Office namespace and schema. --%>­

<html>­

  <WebPartPages:SPWebPartManager runat="server"/>­

  <SharePoint:RobotsMetaTag runat="server"/>­

  <head runat="server">­

    <asp:ContentPlaceHolder runat="server" id="head">­

      <title>­

        <asp:ContentPlaceHolder id="PlaceHolderPageTitle" runat="server" />­

      </title>­

    </asp:ContentPlaceHolder>­

    <Sharepoint:CssLink runat="server"/>­

    <asp:ContentPlaceHolder id="PlaceHolderAdditionalPageHead" runat="server" />­

  </head>­

  <body onload="javascript:_spBodyOnLoadWrapper();">­

    <form runat="server" onsubmit="return _spFormOnSubmitWrapper();">­

      <wssuc:Welcome id="explitLogout" runat="server"/>­

      <PublishingSiteAction:SiteActionMenu runat="server"/>  ­

      <PublishingWebControls:AuthoringContainer id="authoringcontrols" runat="server">­

        <PublishingConsole:Console runat="server" />­

      </PublishingWebControls:AuthoringContainer>­

      <asp:ContentPlaceHolder id="PlaceHolderMain" runat="server" />­

        <asp:Panel visible="false" runat="server">­

<asp:ContentPlaceHolder id="PlaceHolderSearchArea" runat="server"/>­

<asp:ContentPlaceHolder id="PlaceHolderTitleBreadcrumb" runat="server"/>­

<asp:ContentPlaceHolder id="PlaceHolderPageTitleInTitleArea"  runat="server"/>­

<asp:ContentPlaceHolder id="PlaceHolderLeftNavBar" runat="server"/>­

<asp:ContentPlaceHolder ID="PlaceHolderPageImage" runat="server"/>­

<asp:ContentPlaceHolder ID="PlaceHolderBodyLeftBorder" runat="server"/>­

<asp:ContentPlaceHolder ID="PlaceHolderNavSpacer" runat="server"/>­

<asp:ContentPlaceHolder ID="PlaceHolderTitleLeftBorder" runat="server"/>­

<asp:ContentPlaceHolder ID="PlaceHolderTitleAreaSeparator" runat="server"/>­

<asp:ContentPlaceHolder ID="PlaceHolderMiniConsole" runat="server"/>­

<asp:ContentPlaceHolder id="PlaceHolderCalendarNavigator" runat ="server" />­

<asp:ContentPlaceHolder id="PlaceHolderLeftActions" runat ="server"/>­

<asp:ContentPlaceHolder id="PlaceHolderPageDescription" runat ="server"/>­

<asp:ContentPlaceHolder id="PlaceHolderBodyAreaClass" runat ="server"/>­

<asp:ContentPlaceHolder id="PlaceHolderTitleAreaClass" runat ="server"/>­

</asp:Panel>­

    </form>­

  </body>­

</html>­

­

­

­

然后我们来分别认识下这些占位符:­

­

1、<asp:ContentPlaceHolder ID="PlaceHolderGlobalNavigationSiteMap" runat="server" />­

就是一般放在最上面一行显示站点名称的,点击返回到首页;这是占位符,包含控件默认的写法是:­

­

<asp:ContentPlaceHolder id="PlaceHolderGlobalNavigationSiteMap" runat="server">­

    <asp:SiteMapPath SiteMapProvider="SPSiteMapProvider" id="GlobalNavigationSiteMap" RenderCurrentNodeAsLink="true" SkipLinkText="" NodeStyle-CssClass="ms-sitemapdirectional" runat="server"/>­

     </asp:ContentPlaceHolder>­

2、<asp:ContentPlaceHolder ID="PlaceHolderGlobalNavigation" runat="server" />­

放置顶部一行内容的占位符;一般中间可以加上表格,并放上需要的东西,例如欢迎信息,我的站点等。例如欢迎信息:­

­

<asp:ContentPlaceHolder ID="PlaceHolderGlobalNavigation" runat="server">­

<wssuc:Welcome id="IdWelcome" runat="server" EnableViewState="false"></wssuc:Welcome> </asp:ContentPlaceHolder>­

欢迎信息也可以单独拿出来放在其他位置。­

­

­

3、<asp:ContentPlaceHolder ID="PlaceHolderSiteName" runat="server" />­

放置LOGO旁边的大的站点名称的占位符;中间加了内容的默认写法是:­

­

<SharePoint:SPLinkButton runat="server" NavigateUrl="~site/" id="onetidProjectPropertyTitle">­

    <SharePoint:ProjectProperty Property="Title" runat="server" />­

</SharePoint:SPLinkButton>­

posted @ 2010-02-02 15:17  poisson_notes  阅读(628)  评论(1编辑  收藏  举报