【问题标题】:SharePoint 2013 Can't edit the Content Editor snippetSharePoint 2013 无法编辑内容编辑器片段
【发布时间】:2013-03-04 09:19:38
【问题描述】:

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

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

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

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

代码:
生成如下sn-p:

<!--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>

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

我的问题:

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

【问题讨论】:

  • 你解决了吗?
  • 不,我不能花更多的时间在这上面。我们最终没有使页脚可编辑(这对于业务来说是可以接受的,因为内容不会经常更改)。但是,如果有人找到解决此问题的方法,请分享。

标签: sharepoint-2013 web-parts code-snippets content-editor


【解决方案1】:

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

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

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

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

希望它有意义。

【讨论】:

  • 感谢您分享您的想法、确认问题并提供可行的解决方法。我将其标记为答案,因为似乎无法让内容编辑器片段在母版页上工作。解决方法是完成这项工作的一个很好的选择。谢谢!
猜你喜欢
  • 1970-01-01
  • 2016-10-02
  • 1970-01-01
  • 2013-12-12
  • 2011-10-10
  • 2015-09-26
  • 2013-06-04
  • 2012-09-15
  • 2019-07-14
相关资源
最近更新 更多