Putting CEWP into a page in ONET.XML

When you provision sites you can provide various pages (normal pages, not just publishing ones!) However, what if you want to put web parts onto those pages?

Well, you could build multiple pages for your different site configurations. Or you could use a feature receiver to add it programmatically. Or, you could add it via your site configuration.

This is what I found myself doing with the Content Editor web part – I wanted to build it into my site definiton:

<Module Name="CaseSite" Url="" Path="">
<File Url="default.aspx" NavBarHome="True" Type="Ghostable">
<AllUsersWebPart WebPartZoneID="Right" WebPartOrder="1">
<![CDATA[
<WebPart xmlns="http://schemas.microsoft.com/WebPart/v2" xmlns:cewp="http://schemas.microsoft.com/WebPart/v2/ContentEditor">
<Assembly>Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>
<Title>Structral Site Text</Title>
<FrameType>None</FrameType>
<cewp:Content>This is a Case Site</cewp:Content>
</WebPart>
]]>
</AllUsersWebPart>
</File>
</Module>

Here you can see a module deploying a page (default.aspx) and specifying a web part to go at the top of the ‘Right’ web part zone. The XML defines the web part assembly and type, and the content goes into the <cewp:Content> tag.

cewp-displayed

Works nicely – next step, doing this with custom web parts.

Advertisement
Putting CEWP into a page in ONET.XML

2 thoughts on “Putting CEWP into a page in ONET.XML

  1. Ashish says:

    Hi!
    I am not able to include multiline contents (may be with html tags) into tag. But able to add only plain single line of text…
    Please tell me how to achieve that.
    Thanks…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.