1

I have created a page layout using module and aspx page

MyLayout.aspx

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Page Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage" MasterPageFile="~masterurl/default.master" %>

<%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <div>
        <div style="float: left; width: 70%">
            <WebPartPages:WebPartZone
                ID="ActivityStream" runat="server"
                FrameType="TitleBarOnly"
                Title="First Web Part Zone" />
        </div>
        <div style="float: right; width: 30%">
            <div>
                <WebPartPages:WebPartZone
                    ID="Announcements" runat="server"
                    FrameType="TitleBarOnly"
                    Title="Second Web Part Zone" />
            </div>
            <div>
                <WebPartPages:WebPartZone
                    ID="Birthdays" runat="server"
                    FrameType="TitleBarOnly"
                    Title="Third Web Part Zone" />
            </div>
            <div>
                <WebPartPages:WebPartZone
                    ID="PopularPosts" runat="server"
                    FrameType="TitleBarOnly"
                    Title="Fourth Web Part Zone" />
            </div>
        </div>
    </div>
</asp:Content>

Module - Element.xml code

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="MyModule" RootWebOnly="TRUE" Url="Pages">
    <File Path="MyModule\MyLayout.aspx" Url="MyModule\MyLayout.aspx" Type="GhostableInLibrary" />
  </Module>
</Elements>

The above code runs successfully when I change Url in the above Element.xml file to _catalogs/masterpage it doesn't deploy properly.

I also want to include this page layout in the pageLayout dropdown.

enter image description here

3
  • Does your file get deployed to _catalogs/masterpage/MyModule/ ? Commented Oct 31, 2016 at 18:48
  • Also what is your feature scope set to? (Web, Site Collection, web application, farm) Commented Nov 1, 2016 at 13:07
  • My feature scope is Site
    – Madhu
    Commented Nov 1, 2016 at 14:28

1 Answer 1

1

You are using RootWebOnly="TRUE" which will only show the page layout on the top level site of the Site Collection. Also it looks like you are missing some values from your elements file. This is an example from my elements file (your PublishingAssociatedContentType would be different):

<Module Name="Branding" Url="_catalogs/masterpage" List="116">

    <File Path="Branding\Home.aspx" Url="Home.aspx" Type="GhostableInLibrary" Level="Published" ReplaceContent="true">
      <!-- Page Layout Options -->
      <Property Name="ContentTypeId" Value="0x01010007FF3E057FA8AB4AA42FCB67B453FFC100E214EEE741181F4E9F7ACC43278EE81100B432574477BA904292DFD58D26CE0E24" />
      <Property Name="UIVersion" Value="15" />
      <Property Name="ContentType" Value="Page Layout" />
      <Property Name="_ModerationStatus" Value="0" />
      <Property Name="FSObjType" Value="0" />
      <Property Name="PublishingAssociatedContentType" Value=";#HomePage;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D006C1FE3D72BB549E4BD955E452EE10409;#" />
      <!-- Specific Options -->
      <Property Name="Title"
                Value="Home" />
      <Property Name="MasterPageDescription"
                Value="Home Page Layout" />
      <Property Name="PublishingPreviewImage"
                Value="~SiteCollection/_catalogs/masterpage/en-US/Preview Images/ArticleBodyOnly.png, ~SiteCollection/_catalogs/masterpage/en-US/Preview Images/ArticleBodyOnly.png" />
    </File>
2
  • For Content TypeId and PublishingAssociatedContentType Value I have to create content type right
    – Madhu
    Commented Nov 1, 2016 at 11:29
  • I think that is the default ContentTypeId. Commented Nov 1, 2016 at 13:06

Your Answer

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

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