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 LindgrenSep 8, 2013 at 15:36
-
@Robert - could you post that as an answer please (but not just the link, obviously)?– SPDoctorSep 17, 2013 at 8:16
-
Sure! I have tried to extract the most vital details– Robert LindgrenSep 17, 2013 at 9:05
1 Answer
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 <strong>ipsum</strong>
<em>test add</em>" />
</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.– DipeshAug 20, 2018 at 12:55