0

在 SharePoint 2013 中,可以使用新的设计管理器创建母版页和页面布局。将 HTML 文件转换为母版页后,或创建新的页面布局后,可以使用代码段管理器添加 SharePoint 功能。我使用这种方法将静态 HTML/CSS 文件转换为带有随附页面布局的 SharePoint 母版页。我可以使用片段管理器中的所有片段,“内容编辑器”片段除外。我能够添加顶部导航、快速启动栏、页面属性甚至“Web 部件区”片段。

用例:
我想要一个可编辑的页脚。页脚由四个部分组成,因此我通过将片段代码粘贴到 HTML 母版页中添加了四个内容编辑器片段。生成片段时,可以设置自定义属性。我注意到无法在此处设置 WebPartID。在代码段中,始终使用以下 WebPartID:00000000-0000-0000-0000-000000000000。然而,“Web 部件区域”片段将生成(随机?) WebPartID(并且有效)。

问题:
添加片段工作正常,但是当我发布母版页或页面布局时,无法编辑 CEWP。当我编辑使用母版页或页面布局的页面时,CEWP 应该转换为可编辑区域,但事实并非如此。没有显示错误。Web 部件正确呈现自身。

我尝试了什么:
我尝试填写一个随机的 WebPartID,但这不起作用。在 Google 和 StackOverflow 上搜索并没有给我任何线索,我找不到任何面临同样问题的人。

代码:
生成以下代码段:

<!--CS: Start Content Editor Snippet--><!--SPM:<%@Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>--><!--MS:<WebPartPages:ContentEditorWebPart xmlns:WebPartPages="namespace" runat="server" webpart="true">--><!--PS: Start of READ-ONLY PREVIEW (do not modify)--><div class="ms-webpart-chrome ms-webpart-chrome-fullWidth "><div WebPartID="00000000-0000-0000-0000-000000000000" HasPers="true" id="WebPart" width="100%" class="ms-WPBody noindex " OnlyForMePart="true" allowMinimize="false" allowRemove="false" allowDelete="false" style=""><div class="ms-rtestate-field"></div><div class="ms-clear"></div></div></div><!--PE: End of READ-ONLY PREVIEW--><!--MS:<WebPart xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/WebPart/v2">--><!--MS:<Title>--><!--SPM:$Resources:core,ContentEditorWebPartTitle;--><!--ME:</Title>--><!--MS:<FrameType>--><!--SPM:None--><!--ME:</FrameType>--><!--MS:<Description>--><!--SPM:$Resources:core,ContentEditorWebPartDescription;--><!--ME:</Description>--><!--MS:<IsIncluded>--><!--SPM:true--><!--ME:</IsIncluded>--><!--MS:<ZoneID>--><!--SPM:ImportedPartZone--><!--ME:</ZoneID>--><!--MS:<PartOrder>--><!--SPM:0--><!--ME:</PartOrder>--><!--MS:<FrameState>--><!--SPM:Normal--><!--ME:</FrameState>--><!--MS:<Height>--><!--ME:</Height>--><!--MS:<Width>--><!--ME:</Width>--><!--MS:<AllowRemove>--><!--SPM:false--><!--ME:</AllowRemove>--><!--MS:<AllowZoneChange>--><!--SPM:false--><!--ME:</AllowZoneChange>--><!--MS:<AllowMinimize>--><!--SPM:false--><!--ME:</AllowMinimize>--><!--MS:<AllowConnect>--><!--SPM:true--><!--ME:</AllowConnect>--><!--MS:<AllowEdit>--><!--SPM:true--><!--ME:</AllowEdit>--><!--MS:<AllowHide>--><!--SPM:false--><!--ME:</AllowHide>--><!--MS:<IsVisible>--><!--SPM:true--><!--ME:</IsVisible>--><!--MS:<DetailLink>--><!--ME:</DetailLink>--><!--MS:<HelpLink>--><!--ME:</HelpLink>--><!--MS:<HelpMode>--><!--SPM:Modeless--><!--ME:</HelpMode>--><!--MS:<Dir>--><!--SPM:Default--><!--ME:</Dir>--><!--MS:<PartImageSmall>--><!--ME:</PartImageSmall>--><!--MS:<MissingAssembly>--><!--SPM:Cannot import this Web Part.--><!--ME:</MissingAssembly>--><!--MS:<PartImageLarge>--><!--SPM:/_layouts/15/images/mscontl.gif--><!--ME:</PartImageLarge>--><!--MS:<IsIncludedFilter>--><!--ME:</IsIncludedFilter>--><!--MS:<ExportControlledProperties>--><!--SPM:true--><!--ME:</ExportControlledProperties>--><!--MS:<ConnectionID>--><!--SPM:00000000-0000-0000-0000-000000000000--><!--ME:</ConnectionID>--><!--MS:<ID>--><!--SPM:g_2bfa6a66_54d1_45e6_84e7_ebbb461f2911--><!--ME:</ID>--><!--MS:<ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">--><!--ME:</ContentLink>--><!--MS:<Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">--><!--ME:</Content>--><!--MS:<PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor">--><!--ME:</PartStorage>--><!--MS:<ID>--><!--SPM:g_a4deccb6_9661_415d_99c8_51f528cf7428--><!--ME:</ID>--><!--ME:</WebPart>--><!--ME:</WebPartPages:ContentEditorWebPart>--><!--CE: End Content Editor Snippet-->

这会在 .master 文件中生成以下代码:

<WebPartPages:ContentEditorWebPart runat="server" webpart="true" __WebPartId="{B2063517-7C26-4084-AA28-36434C760CDB}"><WebPart xmlns="http://schemas.microsoft.com/WebPart/v2"><Title>$Resources:core,ContentEditorWebPartTitle;</Title><FrameType>None</FrameType><Description>$Resources:core,ContentEditorWebPartDescription;</Description><IsIncluded>true</IsIncluded><PartOrder>0</PartOrder><FrameState>Normal</FrameState><Height /><Width /><AllowRemove>false</AllowRemove><AllowZoneChange>false</AllowZoneChange><AllowMinimize>false</AllowMinimize><AllowConnect>true</AllowConnect><AllowEdit>true</AllowEdit><AllowHide>false</AllowHide><IsVisible>true</IsVisible><DetailLink /><HelpLink /><HelpMode>Modeless</HelpMode><Dir>Default</Dir><PartImageSmall /><MissingAssembly>Cannot import this Web Part.</MissingAssembly><PartImageLarge>/_layouts/15/images/mscontl.gif</PartImageLarge><IsIncludedFilter /><ExportControlledProperties>true</ExportControlledProperties><ConnectionID>00000000-0000-0000-0000-000000000000</ConnectionID><ID>g_2bfa6a66_54d1_45e6_84e7_ebbb461f2911</ID><ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
<Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor"><![CDATA[]]></Content>
<PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" /><ID>g_a4deccb6_9661_415d_99c8_51f528cf7428</ID></WebPart></WebPartPages:ContentEditorWebPart>

更多信息
我将片段粘贴到 HTML 文件中,如图所示。当我添加 Web 部件区域片段时,我可以在其中添加有效的“内容编辑器”WebPart。“Web 部件区”片段仅在页面布局片段管理器中可用,因此我不能将其用作使母版页中的页脚工作的解决方法。

我的问题:

  1. 如何通过 Snippet Manager 添加内容编辑器 WebPart?
  2. 还有其他人面临同样的问题吗?
  3. 保留 WebPartID 00000000-0000-0000-0000-000000000000 可以吗?
4

1 回答 1

1

在这方面与 SharePoint 进行了一些斗争,这就是我发现的:

片段管理器创建的片段有两种不同的工作方式。如果将它们放在母版页或页面布局的 html 代码中的任何位置,它们将具有与您在代码段编辑器中选择的完全相同的配置,之后您将无法对其进行编辑。

但是,如果您将它们放在 Webpart Container Snippet 代码中,您将能够在访问 SharePoint 上的“编辑页面”功能时编辑 Web 部件。您可能已经知道,这仅适用于页面布局,而不适用于母版页。

我相信拥有动态页脚的一种方法是使用 Content By Search Web 部件并将其指向特定列表(页脚列表),在该列表中,您可以拥有一个富文本编辑器类型的列,然后您可以创建一个特定的显示模板,它将根据需要呈现列表内容。

希望它有一些意义。

于 2014-03-14T16:04:54.873 回答