簡體   English   中英

Sharepoint 2010發布網站自定義頁面布局webpart區域

[英]Sharepoint 2010 publishing site custom page layout webpart zone

我正在開發一個具有自定義頁面布局的sharepoint發布網站。 我想將Web部件區域添加到其中一個自定義布局中,該布局顯示默認Web部件,然后用戶可以刪除或更改創建頁面時的屬性。

我正在嘗試這個:

<WebPartPages:WebPartZone id="zone1" runat="server" title="Zone 1">
<ZoneTemplate>
<Something:LookingForLinks runat="server" id="wp_lookingForLinks"/>
</ZoneTemplate>
</WebPartPages:WebPartZone>

Web部件區域可用於添加Web部件,但在創建頁面后,我的默認Web部件不存在。 我在這里錯過了什么嗎?

您還可以將頁面布局部署為單個功能,而不是創建整個網站定義。 這樣,您可以將頁面布局部署到任何SharePoint發布網站。 如果您使用的是VS 2010,請從SharePoint模塊項目開始。 將布局aspx文件添加到項目中。 修改elements.xml文件以使其類似於:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="Page Layouts" Url="_catalogs/masterpage" RootWebOnly="True">
    <File Path="Page Layouts\Layout1.aspx" Url="Layout1.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="True">
      <Property Name="Title" Value="My Layout 1" />
      <Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
    </File>
   </Module>
</Elements>

這將部署您的布局,並使其可用於新的發布頁面。 現在,要在新頁面中實例化webpart,可以使用webpart定義修改<File>元素。 例如,我可以在Zone1中的新頁面上定義要創建的內容編輯器webpart,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="Page Layouts" Url="_catalogs/masterpage" RootWebOnly="True">
    <File Path="Page Layouts\Layout1.aspx" Url="Layout1.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="True">
      <Property Name="Title" Value="My Layout 1" />
      <Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
      <AllUsersWebPart WebPartZoneID="Zone1" WebPartOrder="1">
        <![CDATA[ 
               <WebPart xmlns="http://schemas.microsoft.com/WebPart/v2">
                <Assembly>Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
                <TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>
                <Title>Content Editor</Title>
                <FrameType>Default</FrameType>
                <FrameState>Normal</FrameState>
                <Description></Description>
                <Height />
                <Width />
                <AllowRemove>true</AllowRemove>
                <AllowZoneChange>true</AllowZoneChange>
                <AllowMinimize>true</AllowMinimize>
                <AllowConnect>true</AllowConnect>
                <AllowEdit>true</AllowEdit>
                <AllowHide>true</AllowHide>
                <IsVisible>true</IsVisible>
                <DetailLink />
                <HelpLink />
                <HelpMode>Modeless</HelpMode>
                <Dir>Default</Dir>
                <PartImageSmall />
                <MissingAssembly>Cannot import this Web Part.</MissingAssembly>
                <PartImageLarge>/_layouts/images/homepage.gif</PartImageLarge>
                <IsIncludedFilter />
                <ExportControlledProperties>true</ExportControlledProperties>
                <ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
                <Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">
                </Content>
                <PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
                </WebPart>        
        ]]>
      </AllUsersWebPart>
    </File>
  </Module>
</Elements>

這應該比創建一個全新的網站定義更實用。 希望這可以幫助。

如果使用SharePoint功能部署這些頁面布局並多次激活和取消激活功能,則在重新激活該功能時,Web部件將在頁面上顯示多次。 似乎SharePoint沒有簡單的方法只在頁面上放置一個Web部件實例

我建議使用隨網站定義提供的Onet.xml將webpart添加到頁面。 頁面布局用於提供頁面布局,而不是為自定義網站個性化。 所以請為此目的使用Onet.xml

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM