Working on a site in Sharepoint 2010. I have created a custom page layout with a content editor webpart inside a webpart zone. I want to be able to have the same content appear within the content editor every time a user initially creates a page with this layout. They should have the option to change out the content as needed, but I wanted to have some default content already in the editor upon page creation. Is it possible to prepopulate a content editor webpart in the layout when a user creates a page?
1 Answer
I, like you, was looking for an answer to this. I did finally find it on this MSDN article, but in a roundabout way, so I'll explain it a little better.
When you add the CEWP using SharePoint Designer (making an assumption here), there is a property that gets added, which has a tag inside, . You need to insert a tag inside the CDATA brackets. You can then nest whatever HTML you need inside of the value tag. See below.
<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">
<Title>My Pre-populated Webpart</Title>
<FrameType>None</FrameType>
<Description>Allows authors to enter rich text content.</Description>
<IsIncluded>true</IsIncluded>
<PartOrder>2</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/15/images/mscontl.gif</PartImageLarge>
<IsIncludedFilter />
<ExportControlledProperties>true</ExportControlledProperties>
<ConnectionID>00000000-0000-0000-0000-000000000000</ConnectionID>
<ID>g_8a6ddad9_b2c2_4db6_824b_deac70c5f009</ID>
<ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
<Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor"><![CDATA[<VALUE>
<h1>PREOPULATED TEXT AND STUFF HERE</h1>
</VALUE]]></Content>
<PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
</WebPart>
I know it is a late response, but I hope it helps you, or since it was the first in my results list when I was searching, maybe it will help someone else.