How to Create a Page Layout (PageLayout) with ContentType in SharePoint 2013 – Part II


Sathish Nadarajan
SharePoint MVP
Published On :   16 Nov 2013
Visit Count
Today :  4    Total :   24675
Plan, Migrate, Secure, Report
SharePoint & Office 365 Tool. Simple & Easy to Use. 15-Day Trial!

SharePoint Office 365 Tool
Simple & Powerful Tool for Migration, Security & Reporting. Free Trial


In this article, let us see how to create a PageLayout using SharePoint Designer. In the previous article, we saw about the creating a page layout using Visual Studio. But on that, the PageLayout.aspx, we need to know, how to create the skeleton of the aspx.

We saw that, we need to paste the below lines in the previous post.

 <%@ Page language="C#" Inherits="Microsoft.SharePoint.Publishing.PublishingLayoutPage,Microsoft.SharePoint.Publishing,Version=15.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" %>
 
 <%@ Register Tagprefix="SharePointWebControls" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
 
 <%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
 
 <%@ Register Tagprefix="PublishingWebControls" Namespace="Microsoft.SharePoint.Publishing.WebControls" Assembly="Microsoft.SharePoint.Publishing, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
 
 <%@ Register Tagprefix="PublishingNavigation" Namespace="Microsoft.SharePoint.Publishing.Navigation" Assembly="Microsoft.SharePoint.Publishing, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
 
 <asp:Content ContentPlaceholderID="PlaceHolderPageTitle" runat="server">
 
 <SharePointWebControls:FieldValue id="PageTitle" FieldName="Title" runat="server"/>
 
 </asp:Content>
 
 <asp:Content ContentPlaceholderID="PlaceHolderMain" runat="server">
 
 <ui>
 
 <li ><span style="color:red" >Article Author : </span></li><SharePointWebControls:TextField ID="Author" FieldName="5511034a-38c6-4861-9d00-1633cc111ca3" runat="server"></SharePointWebControls:TextField>
 
 <li ><span style="color:red" >Article Body : </span></li><SharePointWebControls:NoteField ID="Body" FieldName="93bb1031-87a2-4f84-bddb-3a9d94d197d1" runat="server"></SharePointWebControls:NoteField>
 
 <li ><span style="color:red" >Tags : </span></li><SharePointWebControls:CheckBoxChoiceField ID="Tags" FieldName="9736f0e4-9c76-4ff7-bf33-1547ac53553c" runat="server"></SharePointWebControls:CheckBoxChoiceField>
 
 </ui>
 
 </asp:Content>
 
 

We should know, how to get this code.

For that, the usual trick is create the layout on the SharePoint Designer and copy the code. Paste it on the Visual Studio aspx page. Build the wsp. That’s it.

For doing that, let us see how to create a page layout using the SharePoint Designer.

Let us open the Designer.

clip_image002

Open our SiteCollection. Here it is SathishPageLayoutSample.

Designer will somewhat looks like this.

clip_image004

Select the Page Layouts

clip_image006

We can see the list of existing PageLayouts.

clip_image008

On that, Click “New Page Layout” from the ribbon

We will be prompted with the following popup.

clip_image010

Select the Content Type and give the URL and Title.

clip_image012

The layout will be created on the PageLayouts folder.

clip_image014

Open the PageLayoutDemoSPD on the Designer itself and modify how you want the layout should be. Later copy the code and paste it on the Visual Studio. That’s it…….

In the next article, let us plan to do the same thing by Design Manager.

Happy Coding.

Sathish Nadarajan.

SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Categories

Migratiin Tools for SharePoint