1

I am trying to provision a publishing page to the pages library using visual studio. I am using a module and my code looks like below:

 <File Path="CustomPageLayout.aspx" Url="ContactDetails.aspx" ReplaceContent="TRUE"
      Type="GhostableInLibrary">
  <Property Name="Title" Value="Contact Details" />
  <Property Name="MasterPageDescription" Value="" />
  <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/CustomPageLayout.aspx , /_catalogs/masterpage/CustomPageLayout.aspx" />
  <Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
</File>

The page layout is not applied when the page is created. How do I solve this.

I can set the page layout on other pages, so it's working fine, but am having problems on provisioning new pages.

EDIT:

I now updated my code to this:

 <Module Name="Pages" Url="Pages" SetupPath="FEATURES\Website_Website\Website">
        <File Path="CustomPageLayout.aspx" Url="ContactDetails.aspx" ReplaceContent="TRUE" Type="GhostableInLibrary">
            <Property Name="Title" Value="test page" />
            <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/CustomPageLayout.aspx, My Layout" />
            <Property Name="ContentType" Value="Welcome Page" />

       </File>
  </Module>

Since I am deploying my page layout through another feature, so I am using SetupPath. Any idea where I might be wrong here?

2

You need to update your .xml file as below

<File Path="LayoutPage.aspx" Url="InnerPage.aspx"  Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" ReplaceContent="True">
<Property Name="Title" Value="Layout Page"></Property>
<Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
<Property Name="PublishingAssociatedContentType" Value=";#Layout Page;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF390064DEA0F50FC8C147B0B6EA0636C4A7D400181D9406C08A47248593C844813E920D;#" />
<Property Name="FeatureId" Value="$SharePoint.Feature.Id$" Type="string"/>
</File>

Hope this will help you!

  • Can you explain more what corresponds to what? I am provisioning a custom publishing page, you're using contenttype_pagelayout_name as the content type, how come? Also, the content type ID you provided, corresponds to what? page layout content type or page content type? – Jacky Dec 1 '16 at 12:24
1

You provided wrong ContentType value, contenttype_pagelayout_name references page layout content type and usually used to create new page layouts.
Since you are creating a new publishing page, you need to put the value of PublishingAssociatedContentType from corresponding page layout. In your case you need to know which content type is associated with CustomPageLayout.aspx.

For example for out of the box content type, it will be

<Property Name="ContentType" Value="Welcome Page" />

Or via Id:

<Property Name="ContentTypeId" Value="0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF390064DEA0F50FC8C147B0B6EA0636C4A7D4" />   

Also, PublishingPageLayout it's try to provide page layout's name:

<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/CustomPageLayout.aspx, <Page layout name here>" />   

It's a good practice to use SharePoint hive to know the right structure.
For example here is the page layout definition for one of the SharePoint site definitions:

<Module Name="MPGPopulation" Url="_catalogs/masterpage" Path="" RootWebOnly="TRUE">
    <File Url="DefaultLayout.aspx" Type="GhostableInLibrary" >
        <Property Name="Title" Value="$Resources:spscore,DefaultLayoutTitle;" />
        <Property Name="MasterPageDescription" Value="$Resources:spscore,DefaultLayoutDescription;" />
        <Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
        <Property Name="PublishingAssociatedContentType" Value=";#$Resources:cmscore,contenttype_welcomepage_name;;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF390064DEA0F50FC8C147B0B6EA0636C4A7D4;#" />
        <Property Name="PublishingHidden" Value="TRUE" />
    </File>
    ......  

And corresponding publishing page based on this page layout:

<File Url="Default.aspx" Type="GhostableInLibrary">
    <Property Name="Title" Value="$Resources:spscore,HomeLandingPage_Title;" />
    <Property Name="ContentType" Value="$Resources:cmscore,contenttype_welcomepage_name;" /> <--- Welcome Page
    <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/defaultlayout.aspx, $Resources:spscore,DefaultLayoutTitle;" />
    <Property Name="PublishingPageImage" Value="&lt;img border=&quot;0&quot; src=&quot;~SiteCollection/PublishingImages/newsarticleimage.jpg&quot; vspace=&quot;0&quot; style=&quot;margin-top:8px&quot; alt=&quot;&quot;&gt;" />  

UPD
Based on your updated answer you need something similar to this one:

Page Layout:
<File Path="CustomPageLayout.aspx" Url="ContactDetails.aspx" ReplaceContent="TRUE" Type="GhostableInLibrary">
  <Property Name="Title" Value="Contact Details" />
  <Property Name="MasterPageDescription" Value="Contact Details page layout" />
  <Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
  <Property Name="PublishingAssociatedContentType" Value=";#$Resources:cmscore,contenttype_welcomepage_name;;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF390064DEA0F50FC8C147B0B6EA0636C4A7D4;#" />
</File>  
Publishing page based on custom page Layout:
 <Module Name="Pages" Url="Pages" SetupPath="FEATURES\Website_Website\Website">
        <File Path="CustomPageLayout.aspx" Url="ContactDetails.aspx" ReplaceContent="TRUE" Type="GhostableInLibrary">
            <Property Name="Title" Value="test page" />
            <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/ContactDetails.aspx, Contact Details" />
            <Property Name="ContentType" Value="Welcome Page" />
       </File>
  </Module>
  • Hi Kai, isn't the content type for the page layout is going to be the same content type for the page? Since I am using the path = page layout, so am in fact using the same page structure? Will there be a difference in code if I have my page layout provisioned in another project? – Jacky Dec 1 '16 at 12:22
  • Also, spscore,DefaultLayoutTitle; is it an OOB value or this is value provided by you? – Jacky Dec 1 '16 at 12:25
  • _ isn't the content type for the page layout is going to be the same content type for the page_ No, for publishing page you need to use the same content type, specified as PublishingAssociatedContentType for page layout. spscore,DefaultLayoutTitle; is OOB value, since I've posted template from 15 hive – Sergei Sergeev Dec 1 '16 at 12:41
  • Thanks Kai, please see my updated post and code, it still isn't working for me. – Jacky Dec 1 '16 at 12:43
  • Please see my update – Sergei Sergeev Dec 1 '16 at 13:02

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.