0

I Want to add Content Editor in my Page. This has to be done in Page layout. Hence any OOTB solution is not suitable. Any Suggestions?

<WebPartPages:ContentEditorWebPart
                webpart="true"
                runat="server"
               _WebPartId="{D2E2E9C9-554F-4C66-8AB8-07B6EE9D781D}"
               Title="Article Author"
               Description="Web Part Layout"
               PartImageLarge=""
               PartOrder="2"
               ID="g_d18920b4_6273_4d72_97ef_75404fdf7155"
               ChromeType="TitleOnly"
               ContentLink=""
                __WebPartId="{D18920B4-6273-4D72-97EF-75404FDF7155}">
               </WebPartPages:ContentEditorWebPart>
4
  • Are you adding it through SharePoint Designer Maybe try this: Adding CEWP to page layout
    – devnation
    Oct 3, 2017 at 12:52
  • I have to add in page layout not in page
    – Mavani
    Oct 3, 2017 at 12:53
  • I have Created one page layout which one i use in my Content pages. in that layout i want to add one content editor using that content editor i have to change my pages content. guide me how to add content editor in Page Layout????
    – Mavani
    Oct 3, 2017 at 13:02
  • Does the link that devnation posted not work?
    – wjervis
    Oct 3, 2017 at 13:07

1 Answer 1

1

You can add Content Editor web part using Elements.xml file of the Page Layout module in Visual Studio.

You can add CEWP using AllUsersWebPart. Please add below code inside Pagelayout file tag as shown below:

<File Path="PageLayoutModule\DepartmentPageLayout.aspx" Url="PageLayoutModule/DepartmentPageLayout.aspx" Type="GhostableInLibrary" ReplaceContent="TRUE" Level="Published">
      <Property Name="Title" Value="Department PageLayout"/>
      <Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
      <Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/BlankWebPartPage.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/BlankWebPartPage.png" />
      <Property Name="PublishingAssociatedContentType" Value=";#$Resources:cmscore,contenttype_welcomepage_name;;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF390064DEA0F50FC8C147B0B6EA0636C4A7D4;#" />

      <AllUsersWebPart WebPartOrder="1" WebPartZoneID="Overview">
        <![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>Overview Content</Title>
  <FrameType>None</FrameType>
  <ChromeType>None</ChromeType>
  <Description>Allows authors to enter rich text content.</Description>
  <IsIncluded>true</IsIncluded>
  <ZoneID>wp</ZoneID>
  <PartOrder>0</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=14.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;department-overview&quot;&gt;
            /// Your HTML Code here.
            &lt;/div&gt;

  </Content>
        <PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
        </WebPart>

        ]]>
      </AllUsersWebPart>

    </File>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.