Per aggiungere una web part di tipo ContentEditorWebPart a un template di sito (file ONET.XML) in SharePoint 2007 (WSS3 - MOSS) bisogna recuperare l'XML di definizione tramite SharePoint Designer ed aggiungere i seguenti tag:

XML

<Assembly>Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>
va tolto l'attributo ID e inoltre va prestata attenzione ai tag CDATA in quanto non possono essere iseriti direttamente ma vanno sostituiti i tag < e > con le relative entità html (& lt; e & gt;).

Ad esempio se la web part esportata era:

XML

<?xml version="1.0" encoding="utf-8"?>
<WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2">
  <Title>Content Editor Web Part</Title>
  <FrameType>Default</FrameType>
  <Description>Use for formatted text, tables, and images.</Description>
  <IsIncluded>true</IsIncluded>
  <ZoneID>Main</ZoneID>
  <PartOrder>3</PartOrder>
  <FrameState>Normal</FrameState>
  <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/mscontl.gif</PartImageLarge>
  <IsIncludedFilter />
  <Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
  <TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>
  <ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
  <Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor"><![CDATA[<table class="ms-formtoolbar" cellpadding="2" cellspacing="0" border="0" width="100%" >
  <tr>
    <td width="99%" class="ms-toolbar" nowrap="true"><img SRC="/_layouts/images/blank.gif" width="1" height="18" alt="" /></td>
    <td class="ms-toolbar" nowrap="true">
      <table cellpadding="0" cellspacing="0" width="100%">
        <tr>
          <td align="right" width="100%" nowrap="nowrap">
            <input type="button" name="buttonGoBack" value="Close" onclick="STSNavigate(unescapeProperly(GetSource()));return false;" accesskey="C" class="ms-ButtonHeightWidth" target="_self" /> 
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
]]></Content>
  <PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
</WebPart>
inserita in un tag module diventa

XML

<Module Name="TestView" Url="Pages/Test" Path="Pages">
  <File Url="View.aspx" Path="WebPartPage.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE">
    <AllUsersWebPart WebPartZoneID="Main" WebPartOrder="3">
      <![CDATA[<WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/WebPart/v2">
        <Title>Content Editor Web Part</Title>
        <FrameType>Default</FrameType>
        <Description>Use for formatted text, tables, and images.</Description>
        <IsIncluded>true</IsIncluded>
        <ZoneID>Main</ZoneID>
        <PartOrder>3</PartOrder>
        <FrameState>Normal</FrameState>
        <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/mscontl.gif</PartImageLarge>
        <IsIncludedFilter />
        <Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
        <TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>
        <ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
        <Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor"><table class="ms-formtoolbar" cellpadding="2" cellspacing="0" border="0" width="100%" >
        <tr>
        <td width="99%" class="ms-toolbar" nowrap="true"><img SRC="/_layouts/images/blank.gif" width="1" height="18" alt="" /></td>
        <td class="ms-toolbar" nowrap="true">
          <table cellpadding="0" cellspacing="0" width="100%">
          <tr>
            <td align="right" width="100%" nowrap="nowrap">
            <input type="button" name="buttonGoBack" value="Close" onclick="STSNavigate(unescapeProperly(GetSource()));return false;" accesskey="C" class="ms-ButtonHeightWidth" target="_self" /> 
            </td>
          </tr>
          </table>
        </td>
        </tr>
      </table></Content>
      <PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
      </WebPart>]]>
    </AllUsersWebPart>
  </File>
</Module>
dove il CDATA nel tag Content è stato eliminato e tutte i < e > sono stati convertiti nelle rispettive entità html.

Vedi anche CDATA nested inside CDATA when adding Content inside the ContentEditorWebPart
Tags:
SharePoint497 SharePoint 2007218 SharePoint Designer20 XML / XSL / XSLT29
Potrebbe interessarti anche: