Tag Archives: ContentEditorWebPart

How to add a content editor web / ContentEditorWebPart part via your onet.xml or elements manifest

 
<AllUsersWebPart WebPartZoneID="TopZone" WebPartOrder="2">
![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>Web part title</Title>
        <FrameType>None</FrameType>
        <Description>Web part description</Description>
        <FrameState>Normal</FrameState>
        <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">
         &lt;div class=&quot;ms-sblink&quot;&gt;
           &lt;a href=&quot;javascript:HelpWindowKey('how_content_is_searched')&quot;&gt;
             $Resources:spscore,PrivacyStatementWP_LinkText;
           &lt;/a&gt;
        &lt;/div&gt;
        </Content>
        <PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
		</WebPart>             
  ]]> 
</AllUsersWebPart>

The important part here is to remember to html encode the Content element. You can encode html online using this handy website: http://www.opinionatedgeek.com/dotnet/tools/htmlencode/Encode.aspx

Tagged , , ,