MOSS 2007基础:WSS 3.0 中的母版页(Master Pages)和内容页(Content Pages)
原文地址:http://robgarrett.com/cs/blogs/software/archive/2006/07/03/2065.aspx
這篇很短的文章展示了ASP.NET2.0中的母板頁(yè)和內(nèi)容頁(yè)在Windows SharePoint Services v3.0中的應(yīng)用。WSS 3.0 是在ASP.NET 2.0 的基礎(chǔ)上實(shí)現(xiàn)的,所以WSS 3.0中母板頁(yè)/內(nèi)容頁(yè)也是基于ASP.NET 2.0中的相應(yīng)功能而實(shí)現(xiàn)站點(diǎn)定制的。網(wǎng)上已經(jīng)有很多介紹ASP.NET2.0中母版頁(yè)的文章了。下面提供的鏈接來(lái)源與MSDN,個(gè)人認(rèn)為是一篇介紹 ASP.NET 2.0中母版頁(yè)組成結(jié)構(gòu)的很好的入門(mén)文章。
http://msdn.microsoft.com/msdnmag/issues/04/06/ASPNET20MasterPages/
全局母版頁(yè)
母版頁(yè)允許多級(jí)嵌套。所有在sharepoint中的站點(diǎn)都使用default.master這個(gè)母版頁(yè)。這個(gè)文件位于 C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\GLOBAL這個(gè)目錄下。這個(gè)default.master母版頁(yè)是全局母版頁(yè)。任何對(duì)該頁(yè)面的修改將影 響所有的sharepoint站點(diǎn),而且會(huì)影響管理中心站點(diǎn)。
在Sharepoint Designer中編輯母版頁(yè)
SharePoint Designer是原來(lái)的FrontPage的替代工具。SPD(就是sharepoint designer)允許網(wǎng)站設(shè)計(jì)者以可視化的設(shè)計(jì)界面定制sharepoint站點(diǎn)的外觀和樣式。當(dāng)我們打開(kāi)一個(gè)sharepoint站點(diǎn),SPD的左上 方會(huì)列出站點(diǎn)的結(jié)構(gòu)。這個(gè)sharepoint站點(diǎn)里面包括的文件夾,列表,模板和頁(yè)面一目了然。我們要找的母版頁(yè)位于以下路 徑:_catalogs/masterpage/default.master
在設(shè)計(jì)視圖中查看站點(diǎn)的母版頁(yè),在XHTML標(biāo)記中指定了全局母版頁(yè)。在我們對(duì)其做編輯之前,實(shí)際上所有的這個(gè)指向都指到同一個(gè)頁(yè)面。但當(dāng)我們編輯并保存 后,SPD會(huì)在SharePoint的數(shù)據(jù)庫(kù)中為我們保存一個(gè)定制后的母版頁(yè)版本。這和SharePoint 2003中的頁(yè)面定制機(jī)制(或者叫un-ghosting)是一樣的。當(dāng)一個(gè)頁(yè)面被定制后,之前的ghosting關(guān)系就被斷掉了。即不會(huì)在指向磁盤(pán)文件 系統(tǒng)中的某個(gè)文件,而是在數(shù)據(jù)庫(kù)中保存了該頁(yè)面的定制后版本。
注意:在對(duì)站點(diǎn)的母版頁(yè)做了改動(dòng)后,這個(gè)改動(dòng)將影響站點(diǎn)下所有的頁(yè)面。但在_layouts目錄下的頁(yè)面除外。因?yàn)檫@些頁(yè)面實(shí)際上不是站點(diǎn)內(nèi)的頁(yè)面,它們使用了一個(gè)不同的母版頁(yè)(實(shí)際上也放在_layouts目錄下)。這類(lèi)頁(yè)面的一個(gè)典型的例子就是“網(wǎng)站設(shè)置”頁(yè)面。
SPD可以允許我們將已經(jīng)定制過(guò)的頁(yè)面恢復(fù)成原來(lái)的模板指定的狀態(tài)。這是我們?cè)贔rontPage時(shí)代夢(mèng)寐以求的一個(gè)功能。在定制后的頁(yè)面文件上點(diǎn)擊右鍵,在上下文菜單中就包括了這個(gè)選項(xiàng)。
內(nèi)容頁(yè)面
Sharepoint里的內(nèi)容頁(yè)在頁(yè)面聲明中使用MasterPageFile屬性指定了其使用的母版頁(yè)。典型的默認(rèn)母版頁(yè)的URL地 址為~masterurl/default.master。其中的~masterurl指定了該站點(diǎn)的母版頁(yè)的存放位置,所有的這些都是又 sharepoint控制的。在sharepoint的母版頁(yè)中定義了許多占位符(content placeholder)。這些占位符定義了頁(yè)面的不同區(qū)域,開(kāi)發(fā)人員可以定制占位符最終顯示給用戶(hù)的內(nèi)容。SharePoint中定義的占位符中多數(shù)并 不允許用戶(hù)重寫(xiě)其內(nèi)容。
多數(shù)的sharepoint頁(yè)面都包括了PlaceHolderMain這個(gè)占位符,它控制了頁(yè)面的主要內(nèi)容部分。典型情況下,該占位符將包括一個(gè)web部件區(qū)域,用來(lái)拖webpart進(jìn)去。但對(duì)于開(kāi)發(fā)人員來(lái)說(shuō),我們可以用來(lái)放置我們想要放的任何東西。
下面的表格列出了sharepoint的母版頁(yè)中定義的占位符:(詳細(xì)位置請(qǐng)對(duì)照default.master)
| 占位符的Name | 描述 |
| PlaceHolderAdditionalPageHead | 需要寫(xiě)在頁(yè)面<head>標(biāo)簽里的附加內(nèi)容,如引用的腳本或樣式文件 |
| PlaceHolderBodyAreaClass | 附加在頁(yè)面頂部的body中的樣式 |
| PlaceHolderBodyLeftBorder | 頁(yè)面body的邊框元素 |
| PlaceHolderBodyRightMargin | 頁(yè)面body的右邊距 |
| PlaceHolderCalendarNavigator | 在頁(yè)面中有日歷時(shí)為其顯示一個(gè)日期選擇框 |
| PlaceHolderFormDigest | 這是頁(yè)面中必備的 "form digest"安全組件 |
| PlaceHolderGlobalNavigation | 站點(diǎn)導(dǎo)航 |
| PlaceHolderHorizontalNav | 導(dǎo)航標(biāo)簽 |
| PlaceHolderLeftActions | 左側(cè)導(dǎo)航區(qū)下面的動(dòng)作區(qū) |
| PlaceHolderLeftNavBar | 左側(cè)導(dǎo)航區(qū) |
| PlaceHolderLeftNavBarBorder | 左側(cè)導(dǎo)航區(qū)的邊框元素 |
| PlaceHolderLeftNavBarDataSource | 左側(cè)導(dǎo)航區(qū)菜單的數(shù)據(jù)源 |
| PlaceHolderLeftNavBarTop | 左側(cè)導(dǎo)航區(qū)上面的導(dǎo)航區(qū) |
| PlaceHolderMain | 頁(yè)面主體 |
| PlaceHolderMiniConsole | 一個(gè)放置頁(yè)面級(jí)命令的地方,比如在WIKI站點(diǎn)里的Edit Page, History, Incoming Links |
| PlaceHolderNavSpacer | 左側(cè)導(dǎo)航區(qū)的寬度 |
| PlaceHolderPageDescription | 頁(yè)面描述區(qū) |
| PlaceHolderPageImage | 頁(yè)面左上的圖標(biāo) |
| PlaceHolderPageTitle | 頁(yè)面的<Title>,通常顯示在瀏覽器的標(biāo)題欄 |
| PlaceHolderSearchArea | 搜索框 |
| PlaceHolderSiteName | 站點(diǎn)名稱(chēng) |
| PlaceHolderTitleAreaClass | TitleArea附加的樣式 |
| PlaceHolderTitleAreaSeparator | TitleAreaSeparator區(qū) |
| PlaceHolderTitleBreadcrumb | TitleBreadcrumb區(qū) |
| PlaceHolderTitleInTitleArea | Breadcrumb區(qū)下面的標(biāo)題 |
| PlaceHolderTitleLeftBorder | Title區(qū)左側(cè)邊框 |
| PlaceHolderTitleRightMargin | Title區(qū)右側(cè)空白 |
| PlaceHolderTopNavBar | 標(biāo)簽導(dǎo)航區(qū) |
| PlaceHolderUtilityContent | 頁(yè)面底部需要的一塊特殊內(nèi)容 |
| SPNavigation | 在 Windows SharePoint Services中默認(rèn)為空,用于附加的頁(yè)面編輯控件 |
| WSSDesignConsole | 頁(yè)面編輯控件,當(dāng)頁(yè)面進(jìn)入編輯頁(yè)面模式時(shí)使用(當(dāng)我們點(diǎn) Site Actions, Edit 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的母版頁(yè)中定義的所有占位符:(詳細(xì)位置請(qǐng)對(duì)照default.master)
1、<asp:ContentPlaceHolder ID="PlaceHolderGlobalNavigationSiteMap" runat="server" />
放置連接到頂級(jí)站點(diǎn)的超連接
2、<asp:ContentPlaceHolder ID="PlaceHolderGlobalNavigation" runat="server" />
放置頂部一行內(nèi)容。
3、<asp:ContentPlaceHolder ID="PlaceHolderSiteName" runat="server" />
放置站點(diǎn)名稱(chēng)
4、<asp:ContentPlaceHolder ID="PlaceHolderSearchArea" runat="server" />
放置搜索框
5、<asp:ContentPlaceHolder ID="PlaceHolderHorizontalNav" runat="server" />
放置水平導(dǎo)航欄
6、<asp:ContentPlaceHolder ID="PlaceHolderTopNavBar" runat="server" />
放置水平導(dǎo)航欄一行內(nèi)容。
7、<asp:ContentPlaceHolder ID="WSSDesignConsole" runat="server" />
頁(yè)面編輯控件,當(dāng)頁(yè)面進(jìn)入編輯頁(yè)面模式時(shí)使用(當(dāng)我們點(diǎn) Site Actions, Edit Page后)
8、<asp:ContentPlaceHolder ID="SPNavigation" runat="server" />
在 Windows SharePoint Services中默認(rèn)為空,用于附加的頁(yè)面編輯控件
9、<asp:ContentPlaceHolder ID="PlaceHolderPageImage" runat="server" />
左側(cè)的圖片
10、<asp:ContentPlaceHolder ID="PlaceHolderTitleLeftBorder" runat="server" />
Title區(qū)左側(cè)邊框
11、<asp:ContentPlaceHolder ID="PlaceHolderTitleBreadcrumb" runat="server" />
TitleBreadcrumb頁(yè)面導(dǎo)航區(qū)
12、<asp:ContentPlaceHolder ID="PlaceHolderPageTitleInTitleArea" runat="server" />
Breadcrumb區(qū)下面的標(biāo)題
13、<asp:ContentPlaceHolder ID="PlaceHolderMiniConsole" runat="server" />
一個(gè)放置頁(yè)面級(jí)命令的地方,比如在WIKI站點(diǎn)里的Edit Page, History, Incoming Links
14、<asp:ContentPlaceHolder ID="PlaceHolderTitleRightMargin" runat="server" />
Title區(qū)右側(cè)空白
15、<asp:ContentPlaceHolder ID="PlaceHolderTitleAreaSeparator" runat="server" />
TitleAreaSeparator區(qū)
16、<asp:ContentPlaceHolder ID="PlaceHolderLeftNavBarDataSource" runat="server" />
左側(cè)導(dǎo)航區(qū)數(shù)據(jù)源
17、<asp:ContentPlaceHolder ID="PlaceHolderCalendarNavigator" runat="server" />
在頁(yè)面中有日歷時(shí)為其顯示一個(gè)日期選擇框
18、<asp:ContentPlaceHolder ID="PlaceHolderLeftNavBarTop" runat="server" />
左側(cè)導(dǎo)航區(qū)上面的導(dǎo)航區(qū)
19、<asp:ContentPlaceHolder ID="PlaceHolderLeftNavBar" runat="server" />
左側(cè)導(dǎo)航區(qū)
20、<asp:ContentPlaceHolder ID="PlaceHolderLeftActions" runat="server" />
左側(cè)導(dǎo)航區(qū)下面的動(dòng)作區(qū)
21、<asp:ContentPlaceHolder ID="PlaceHolderNavSpacer" runat="server" />
左側(cè)導(dǎo)航區(qū)的寬度
22、<asp:ContentPlaceHolder ID="PlaceHolderLeftNavBarBorder" runat="server" />
左側(cè)導(dǎo)航區(qū)的邊框元素
23、<asp:ContentPlaceHolder ID="PlaceHolderBodyLeftBorder" runat="server" />
頁(yè)面body的邊框元素
24、<asp:ContentPlaceHolder id="PlaceHolderPageDescription" runat="server" />
頁(yè)面描述區(qū)
25、<asp:ContentPlaceHolder id="PlaceHolderMain" runat="server" />
頁(yè)面主體
26、<asp:ContentPlaceHolder ID="PlaceHolderBodyRightMargin" runat="server" />
頁(yè)面body的右邊空白
27、<asp:ContentPlaceHolder ID="PlaceHolderFormDigest" runat="server"/>
這是頁(yè)面中必備的 "form digest"安全組件。
28、<asp:ContentPlaceHolder ID="PlaceHolderUtilityContent" runat="server" />
頁(yè)面底部需要的一塊特殊內(nèi)容
29、<asp:ContentPlaceHolder ID="PlaceHolderBodyAreaClass" runat="server" />
附加在頁(yè)面頂部的body中的樣式
30、<asp:ContentPlaceHolder ID="PlaceHolderTitleAreaClass" runat="server" />
TitleArea附加的樣式
31、<asp:ContentPlaceHolder id="PlaceHolderAdditionalPageHead" runat="server" />
提供給內(nèi)容頁(yè)添加所有可以放在<head>區(qū)域的內(nèi)容,如CSS、JS等。
轉(zhuǎn)載于:https://www.cnblogs.com/bmib/archive/2011/03/23/1992476.html
總結(jié)
以上是生活随笔為你收集整理的MOSS 2007基础:WSS 3.0 中的母版页(Master Pages)和内容页(Content Pages)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 转载:js跨域问题小结
- 下一篇: 2010所有用户