sharepoint 2007 page

原文地址:http://robgarrett.com/cs/blogs/software/archive/2006/07/03/2065.aspx
这篇很短的文章展示了ASP.NET2.0中的母板页和内容页在Windows SharePoint Services v3.0中的应用。WSS 3.0 是在ASP.NET 2.0 的基础上实现的,所以WSS 3.0中母板页/内容页也是基于ASP.NET 2.0中的相应功能而实现站点定制的。网上已经有很多介绍ASP.NET2.0中母版页的文章了。下面提供的链接来源与MSDN,个人认为是一篇介绍 ASP.NET 2.0中母版页组成结构的很好的入门文章。
http://msdn.microsoft.com/msdnmag/issues/04/06/ASPNET20MasterPages/
全局母版页
母版页允许多级嵌套。所有在sharepoint中的站点都使用default.master这个母版页。这个文件位于 C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\GLOBAL这个目录下。这个default.master母版页是全局母版页。任何对该页面的修改将影 响所有的sharepoint站点,而且会影响管理中心站点。
在Sharepoint Designer中编辑母版页
SharePoint Designer是原来的FrontPage的替代工具。SPD(就是sharepoint designer)允许网站设计者以可视化的设计界面定制sharepoint站点的外观和样式。当我们打开一个sharepoint站点,SPD的左上 方会列出站点的结构。这个sharepoint站点里面包括的文件夹,列表,模板和页面一目了然。我们要找的母版页位于以下路 径:_catalogs/masterpage/default.master
在设计视图中查看站点的母版页,在XHTML标记中指定了全局母版页。在我们对其做编辑之前,实际上所有的这个指向都指到同一个页面。但当我们编辑并保存 后,SPD会在SharePoint的数据库中为我们保存一个定制后的母版页版本。这和SharePoint 2003中的页面定制机制(或者叫un-ghosting)是一样的。当一个页面被定制后,之前的ghosting关系就被断掉了。即不会在指向磁盘文件 系统中的某个文件,而是在数据库中保存了该页面的定制后版本。
注意:在对站点的母版页做了改动后,这个改动将影响站点下所有的页面。但在_layouts目录下的页面除外。因为这些页面实际上不是站点内的页面,它们使用了一个不同的母版页(实际上也放在_layouts目录下)。这类页面的一个典型的例子就是“网站设置”页面。
SPD可以允许我们将已经定制过的页面恢复成原来的模板指定的状态。这是我们在FrontPage时代梦寐以求的一个功能。在定制后的页面文件上点击右键,在上下文菜单中就包括了这个选项。
内容页面
Sharepoint里的内容页在页面声明中使用MasterPageFile属性指定了其使用的母版页。典型的默认母版页的URL地 址为~masterurl/default.master。其中的~masterurl指定了该站点的母版页的存放位置,所有的这些都是又 sharepoint控制的。在sharepoint的母版页中定义了许多占位符(content placeholder)。这些占位符定义了页面的不同区域,开发人员可以定制占位符最终显示给用户的内容。SharePoint中定义的占位符中多数并 不允许用户重写其内容。
多数的sharepoint页面都包括了PlaceHolderMain这个占位符,它控制了页面的主要内容部分。典型情况下,该占位符将包括一个web部件区域,用来拖webpart进去。但对于开发人员来说,我们可以用来放置我们想要放的任何东西。
下面的表格列出了sharepoint的母版页中定义的占位符:(详细位置请对照default.master)

占位符的Name

描述

PlaceHolderAdditionalPageHead

需要写在页面<head>标签里的附加内容,如引用的脚本或样式文件

PlaceHolderBodyAreaClass

附加在页面顶部的body中的样式

PlaceHolderBodyLeftBorder

页面body的边框元素

PlaceHolderBodyRightMargin

页面body的右边距

PlaceHolderCalendarNavigator

在页面中有日历时为其显示一个日期选择框

PlaceHolderFormDigest

这是页面中必备的 "form digest"安全组件

PlaceHolderGlobalNavigation

站点导航

PlaceHolderHorizontalNav

导航标签

PlaceHolderLeftActions

左侧导航区下面的动作区

PlaceHolderLeftNavBar

左侧导航区

PlaceHolderLeftNavBarBorder

左侧导航区的边框元素

PlaceHolderLeftNavBarDataSource

左侧导航区菜单的数据源

PlaceHolderLeftNavBarTop

左侧导航区上面的导航区

PlaceHolderMain

页面主体

PlaceHolderMiniConsole

一个放置页面级命令的地方,比如在WIKI站点里的Edit Page, History, Incoming Links

PlaceHolderNavSpacer

左侧导航区的宽度

PlaceHolderPageDescription

页面描述区

PlaceHolderPageImage

页面左上的图标

PlaceHolderPageTitle

页面的<Title>,通常显示在浏览器的标题栏

PlaceHolderSearchArea

搜索框

PlaceHolderSiteName

站点名称

PlaceHolderTitleAreaClass

TitleArea附加的样式

PlaceHolderTitleAreaSeparator

TitleAreaSeparator

PlaceHolderTitleBreadcrumb

TitleBreadcrumb

PlaceHolderTitleInTitleArea

Breadcrumb区下面的标题

PlaceHolderTitleLeftBorder

Title区左侧边框

PlaceHolderTitleRightMargin

Title区右侧空白

PlaceHolderTopNavBar

标签导航区

PlaceHolderUtilityContent

页面底部需要的一块特殊内容

SPNavigation

 Windows SharePoint Services中默认为空,用于附加的页面编辑控件

WSSDesignConsole

页面编辑控件,当页面进入编辑页面模式时使用(当我们点 Site ActionsEdit Page)

Localized images in MOSS Masterpage / Page Layouts

Recently I had to create a MOSS masterpage with localized images on it. In other words, the images contain text or other content that should change depending on the language of the site. It took me quite some time to find out how to do this gracefully but I think this is the best way to do it.

I normally store all images in the /Style Library/Images folder on the server. To distinguish the localized images I created language-folders in this folder that contain the image in that language. For instance, an image called "locallogo.png" would be stored in /Style Library/Images/en-US as well as in /Style Library/Images/nl-NL where the en-US and nl-NL correspond to the locale of the all the different languages on your site.
Now, on the masterpage we can reference both these images like this:

<img runat="server" src="<% $SPUrl:~SiteCollection/Style Library/Images/~language/locallogo.png%>" />

The first thing you'll notice is the runat="server" part. This tells moss that the tag contains asp.net code that should be executed on the server. The second important thing on this line is the ~language part. This is a special MOSS marker that is replaced on the server by the locale of the current page, for instance, en-US. Because we placed the image in folders that also had locale-names, we will always have a reference to the image in the correct language!

 

下面列出了sharepoint的母版页中定义的所有占位符:(详细位置请对照default.master)
1 < asp:ContentPlaceHolder ID = " PlaceHolderGlobalNavigationSiteMap " runat = " server " />
放置连接到顶级站点的超连接
2 < asp:ContentPlaceHolder ID = " PlaceHolderGlobalNavigation " runat = " server " />
放置顶部一行内容。
3 < asp:ContentPlaceHolder ID = " PlaceHolderSiteName " runat = " server " />
放置站点名称
4 < asp:ContentPlaceHolder ID = " PlaceHolderSearchArea " runat = " server " />
放置搜索框
5 < asp:ContentPlaceHolder ID = " PlaceHolderHorizontalNav " runat = " server " />
放置水平导航栏
6 < asp:ContentPlaceHolder ID = " PlaceHolderTopNavBar " runat = " server " />
放置水平导航栏一行内容。
7 < asp:ContentPlaceHolder ID = " WSSDesignConsole " runat = " server " />
页面编辑控件,当页面进入编辑页面模式时使用(当我们点 Site Actions, Edit Page后)
8 < asp:ContentPlaceHolder ID = " SPNavigation " runat = " server " />
在 Windows SharePoint Services中默认为空,用于附加的页面编辑控件
9 < asp:ContentPlaceHolder ID = " PlaceHolderPageImage " runat = " server " />
左侧的图片
10 < asp:ContentPlaceHolder ID = " PlaceHolderTitleLeftBorder " runat = " server " />
Title区左侧边框
11 < asp:ContentPlaceHolder ID = " PlaceHolderTitleBreadcrumb " runat = " server " />
TitleBreadcrumb页面导航区
12 < asp:ContentPlaceHolder ID = " PlaceHolderPageTitleInTitleArea " runat = " server " />
Breadcrumb区下面的标题
13 < asp:ContentPlaceHolder ID = " PlaceHolderMiniConsole " runat = " server " />
一个放置页面级命令的地方,比如在WIKI站点里的Edit Page, History, Incoming Links
14 < asp:ContentPlaceHolder ID = " PlaceHolderTitleRightMargin " runat = " server " />
Title区右侧空白
15 < asp:ContentPlaceHolder ID = " PlaceHolderTitleAreaSeparator " runat = " server " />
TitleAreaSeparator区
16 < asp:ContentPlaceHolder ID = " PlaceHolderLeftNavBarDataSource " runat = " server " />
左侧导航区数据源
17 < asp:ContentPlaceHolder ID = " PlaceHolderCalendarNavigator " runat = " server " />
在页面中有日历时为其显示一个日期选择框
18 < asp:ContentPlaceHolder ID = " PlaceHolderLeftNavBarTop " runat = " server " />
左侧导航区上面的导航区
19 < asp:ContentPlaceHolder ID = " PlaceHolderLeftNavBar " runat = " server " />
左侧导航区
20 < asp:ContentPlaceHolder ID = " PlaceHolderLeftActions " runat = " server " />
左侧导航区下面的动作区
21 < asp:ContentPlaceHolder ID = " PlaceHolderNavSpacer " runat = " server " />
左侧导航区的宽度
22 < asp:ContentPlaceHolder ID = " PlaceHolderLeftNavBarBorder " runat = " server " />
左侧导航区的边框元素
23 < asp:ContentPlaceHolder ID = " PlaceHolderBodyLeftBorder " runat = " server " />
页面body的边框元素
24 < asp:ContentPlaceHolder id = " PlaceHolderPageDescription " runat = " server " />
页面描述区
25 < asp:ContentPlaceHolder id = " PlaceHolderMain " runat = " server " />
页面主体
26 < asp:ContentPlaceHolder ID = " PlaceHolderBodyRightMargin " runat = " server " />
页面body的右边空白
27 < asp:ContentPlaceHolder ID = " PlaceHolderFormDigest " runat = " server " />
这是页面中必备的
" form digest " 安全组件。
28 < asp:ContentPlaceHolder ID = " PlaceHolderUtilityContent " runat = " server " />
页面底部需要的一块特殊内容
29 < asp:ContentPlaceHolder ID = " PlaceHolderBodyAreaClass " runat = " server " />
附加在页面顶部的body中的样式
30 < asp:ContentPlaceHolder ID = " PlaceHolderTitleAreaClass " runat = " server " />
TitleArea附加的样式
31 < asp:ContentPlaceHolder id = " PlaceHolderAdditionalPageHead " runat = " server " />
提供给内容页添加所有可以放在
< head > 区域的内容,如CSS、JS等。

你可能感兴趣的:(SharePoint)