0

I have create page layout and uploaded it to the master page gallery in a module, now I want to create a publishing page from this page layout, I know I should use a module and upload an .aspx page to the pages library. But what's the content of this .aspx page will be? for my page layout I know the exact html and everything, but for my publishing page what should I write inside? should I create an .aspx page with minimal html?

  • Take a look at Waldek's excellent post: blog.mastykarz.nl/… – Robert Lindgren Sep 8 '13 at 15:36
  • @Robert - could you post that as an answer please (but not just the link, obviously)? – SPDoctor Sep 17 '13 at 8:16
  • Sure! I have tried to extract the most vital details – Robert Lindgren Sep 17 '13 at 9:05
3

You can provision publishing pages using modules.

Add a new module to your project, and add the module to a feature.

Add a file to the module (in this case named TemplatePage.aspx) with the following content:

<%@ Page
Inherits="Microsoft.SharePoint.Publishing.TemplateRedirectionPage,
Microsoft.SharePoint.Publishing,Version=12.0.0.0,Culture=neutral,
PublicKeyToken=71e9bce111e9429c" %>
<%@ Reference VirtualPath="~TemplatePageUrl" %>
<%@ Reference VirtualPath="~masterurl/custom.master" %>

In the Elements.xml of the module you can use the following structure:

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="Pages"
    Url="$Resources:cmscore,List_Pages_UrlName;">
    <File Name="Page1.aspx" Url="Page1.aspx"
      Path="TemplatePage.aspx" Type="GhostableInLibrary"
      IgnoreIfAlreadyExists="TRUE">
      <Property Name="Title" Value="Lipsum"/>
      <Property Name="PublishingPageLayout"
        Value="~SiteCollection/_catalogs/masterpage/MyLayout.aspx,
        /_catalogs/masterpage/MyLayout.aspx"/>
      <Property Name="ContentType" Value="My page CT" />
      <Property Name="ContentTypeId"
        Value="0x010100C568DB52D9D0A14D9B2FDCC96666E9F200794..." />
      <Property Name="PublishingPageContent"
        Value="Lorem &lt;strong&gt;ipsum&lt;/strong&gt;
        &lt;em&gt;test add&lt;/em&gt;" />
    </File>
  </Module>
</Elements>

As you can see you can modify the values for ContentType, ContentTypeId, PublishingPageLayout, Title and PublishingPageContent to match your project.

Waldek Mastykarz has an excellent and detailed walk-through here

  • I am trying to provision publishing page using Out Of the Box "Blank Page layout" which can be found at /_catalogs/masterpage/PageFromDocLayout.aspx. And add Content Editor webpart to that page. Can you please post how it can be achieve? PS: My end goal is to package SharePoint List and Pages (which includes customization using Content Editor Webpart). So that it can be easily deployed to any other machine. – Dipesh Aug 20 '18 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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