我是新來的分享點。我有一個C#解決方案,它有在masterpoint站點中使用的masterpages和用戶控件。我已經安裝了我的sharepoint dev虛擬機,我可以瀏覽默認的sharepoint資料。我有一個分享點解決方案,下一步是什麼
如何添加母版頁到SharePoint?我從哪裏出發?
我是新來的分享點。我有一個C#解決方案,它有在masterpoint站點中使用的masterpages和用戶控件。我已經安裝了我的sharepoint dev虛擬機,我可以瀏覽默認的sharepoint資料。我有一個分享點解決方案,下一步是什麼
如何添加母版頁到SharePoint?我從哪裏出發?
我的建議是部署母版頁的功能,而不是一個手動過程。解決方案(WSP)和功能是將內容/功能部署到共享點的支持方式。一個真正偉大的SharePoint開發工具叫做WSPBuilder
一個母版頁作爲一個「模塊」部署到sharepoint中,您將把它放到元素中的elements.xml文件中。
認爲一個溶液與不同的擴展名的CAB文件的。其中包含一個名爲feature.xml的文件,該文件定義了包的部署標題。您可以啓用和停用功能,以將您的內容部署到您的服務器場的某些部分並取消部署。
這裏是部署爲一個模塊一個CSS文件的例子...母版頁有異曲同工之處然而,他們將部署到母版頁庫,而不是樣式庫。此模塊將自定義CSS文件部署到網站集的「樣式庫」中。部署完成後,我使用「Feature Receiver」(事件處理程序)來獲取SPSite對象的引用並修改其替代樣式表,以便進行覆蓋。
的Feature.xml
<?xml version="1.0" encoding="utf-8" ?>
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
Id="63BB13A0-1F9C-4c3b-BE60-10E59CEE0113"
Title="Custom CSS Feature"
Description="Deploying a custom CSS using a feature"
Version="1.0.0.0"
Hidden="FALSE"
Scope="Site"
ReceiverAssembly="CustomCSSFeature, Version=1.0.0.0, Culture=neutral, PublicKeyToken=24f1377a8414d2ed"
ReceiverClass="CustomCSSFeature.FeatureReceivers.CustomCSSFeatureReceiver"
>
<ElementManifests>
<ElementManifest Location="elements.xml"/>
</ElementManifests>
</Feature>
elements.xml中 - 你會修改這個以反映母版頁都應該被部署我會認爲這是Url屬性。路徑=「樣式」是指相對路徑的功能本身在樣式表所在內(例如,在你的視覺工作室,我有叫叫CustomCSSFeature的文件夾下面樣式的子文件夾,這是在樣式表存在)
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="OSGStyles" Url="Style Library" Path="Styles" RootWebOnly="TRUE">
<File Url="custom-css.css" Type="GhostableInLibrary" />
</Module>
</Elements>
然後,在我的功能接收器類我已經激活/停用該「應用」樣式表到發佈網絡處理器。在你的情況下,你可能會改變功能接收器中網站的默認主頁面。
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPSite site = properties.Feature.Parent as SPSite;
using (SPWeb web = site.OpenWeb())
{
PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
publishingWeb.AlternateCssUrl.SetValue(web.ServerRelativeUrl +
"/Style Library/custom-css.css", true);
publishingWeb.Update();
web.Update();
}
}
public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
{
SPSite site = properties.Feature.Parent as SPSite;
using (SPWeb web = site.OpenWeb())
{
PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web);
publishingWeb.AlternateCssUrl.SetValue("", true);
publishingWeb.Update();
web.Update();
}
}
非常感謝,讓我開始了。該解決方案有一些用戶控件。主頁面使用絕對路徑引用這些控件。 部署過程是否與控件相同,並且一旦我部署了它們,我如何從主頁面引用它們? – robasta 2010-07-15 07:34:16
在將它們作爲內容文件部署到12頁佈局或控制模板後,您可以在母版頁中聲明它們。 例如<@ Register TagPrefix =「ctrl」src =「/ _controltemplates(或_layouts)/MyFeatureName/MyControl.ascx」> 在這兩種情況下,您都需要將解決方案的.ascx部分部署到模板/佈局的子文件夾中或更好的控制模板的子文件夾使用.wsp [Heather solomon](http://www.heathersolomon.com/blog/articles/servermstpageforsitecollect_feature.aspx)有一個很好的例子,作爲功能部署的母版頁。 – 2010-07-15 15:36:58
此外,[用戶控制大師](http://www.learningsharepoint.com/2010/06/27/add-user-control-in-sharepoint-master-page/) – 2010-07-15 15:37:54
將它們複製到SharePoint根目錄(SP 2007默認位置是C:\Program Files\Common Files\microsoft shared\Web Server Extensions\12\
,2010年SP,而不是「12」,你有「SharePointRoot」)
從那裏,你的文件複製到\TEMPLATE\LAYOUTS
文件夾,然後你可以參考一下來自你的aspx頁面的masterpage,比如「/_layouts/mymasterpage.master」。
用戶控件進入\TEMPLATE\CONTROLTEMPLATES
Get to know the directory structure in the 12 Hive
Exploring the 12 Hive : TEMPLATE Directory
另一種方法是把你的母版在母版頁列表。使用此鏈接訪問母版頁列表,並上傳你的母版:HTTP:/// _目錄/母版
您可以添加使用SharePoint Designer 2007母版頁。
一般來說,我建議你看看這個問題的答案:Learning Sharepoint
你可以,但你真的不應該。如果你打算只將它添加到一臺服務器上,它可能就是okey。如果您最初認爲對於一個或多個場景「不」,您應該將主頁面放入功能/解決方案中。 – 2010-07-15 12:25:15
我同意一個功能/解決方案通常是更好的方法。但Sharepoint Designer是一個正確的答案,Robert Dondo應該很快看到結果,而且我對他的場景一無所知。我爲他提供了「學習Sharepoint」的鏈接,作爲了解更多信息的出發點。 – user4531 2010-07-19 08:42:07
另一個教程這裏:http://sharepointmagazine.net/technical/development/introduction-to-master-pages – robasta 2010-07-22 07:38:36