PowerShell : Change the Layout of the SharePoint Page

Sathish Nadarajan
 
Solution Architect
July 9, 2021
 
Rate this article
 
Views
2150

In SharePoint Online, when we create a new modern page, by default, the header of the page is coming as below. Sometimes, we don’t want that to be displayed. To hide the title bar, we can change the layout of the page itself.

 

#Connect to SharePoint Online site
$SiteURL = "https://sppalsmvp.sharepoint.com/sites/ReactRepository/"
Connect-PnPOnline $SiteURL -Credential (Get-Credential)

#Get the ID of the Page
Get-PnPListItem -List SitePages

#Change Page layout from "Article" to "Home"
Set-PnPListItem -List SitePages –Identity "13" -Values @{"PageLayoutType"="Home"}

Then, the title bar will not appear on this layout.

Happy Coding
Sathish Nadarajan

Author Info

Sathish Nadarajan
 
Solution Architect
 
Rate this article
 
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 15+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business ...read more
 

SharePoint Tip :- Hide the Title Area on SharePoint Modern Page

Sathish Nadarajan
 
Solution Architect
July 18, 2020
 
Rate this article
 
Views
9374

In this article, let us see a Simple SharePoint tip to hide the Title Area of an Article Page in SharePoint Online. Usually when I create a page in the Modern Site, the title area will be shown as below. Even, If I delete the title, the section will be shown as below.

But, my requirement is, to hide them and there are possibilities through CSS. But a permanent solution will be, creating the Page using the layout “Home” instead of “Article”. By default, we were not able to create a layout with a defined layout in modern page. Hence, after creating, using the below PowerShell script, we can convert the layout and the Title Area will be automatically hided.

$SiteURL = "https://MYSite.sharepoint.com/sites/MySiteCollection/"
Connect-PnPOnline $SiteURL -Credential (Get-Credential)

Get-PnPListItem -List SitePages

Set-PnPListItem -List SitePages –Identity "5" -Values @{"PageLayoutType"="Home"}

After converting the page looks as below.

A small tip which will help to convert the page layout.

Happy Coding
Sathish Nadarajan

Author Info

Sathish Nadarajan
 
Solution Architect
 
Rate this article
 
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 15+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business ...read more
 

Is it possible to create a modern SPFx web part as a control in Page Layout (Template)?

Manimekalai
 
Technology Specialist
April 1, 2018
 
Rate this article
 
Views
2930

There are many question whether it is possible to create a modern SPFx web part as a control in Page Layout (Template).

Yes, there is a workaround which is far from ideal but works:

· Export your SPFx webpart from the browser (.webpart file).

· Upload the .webpart file to the webpart gallery.

· Open SharePoint designer

· Navigate to page layouts folder from your SharePoint designer

· Right click on your page layouts

· Open the page layouts (ie: .aspx) as preview in browser

· Manually edit the aspx file in browser by clicking on edit button or by navigating using the URL “?ToolPaneView=2&pagemode=edit”

· Add the required SPFx webpart from the “Add Webpart” section.

· Save the aspx and when you create a page using the page layout, your SPFx webpart should be there.

Note: Please ignore the error while saving the .aspx page from browser. Just refresh your page then webpart will get added automatically.

Here you go!

Your page layout is ready with SPFx webpart.

Category : Office 365, SharePoint, SPFx

Author Info

Manimekalai
 
Technology Specialist
 
Rate this article
 
Having 6 years of experience in design and development of SharePoint applications, Mani has expertise in developing applications using Office 365, SharePoint 2013 & 2010, SPFX, SP Designer Workflows, Visual ...read more
 

How to Set the Page Layout in SharePoint 2013 using PowerShell

Sathish Nadarajan
 
Solution Architect
December 5, 2015
 
Rate this article
 
Views
11747

In this article, let us see how to change the PageLayout of a Publishing page using PowerShell in SharePoint 2013. All the PowerShell Scripts will be very much helpful and handy during the time of preparing the deployment package.

The Script is straight forward and does not require any explanation I guess.

 ##================================================================================================
 ## Description	: To do the below two items.
     #1. Update the PageLayouts of the Existing Pages
 ## Author		: Sathish Nadarajan
 ## Date			: 16-Nov-2015
 ##================================================================================================
 
 ##============================================ Setup Input Paths ===========================================================
 
 cls
  
 $Host.UI.RawUI.WindowTitle = "-- Update the Page Layouts of the Existing Pages --"
 
 $StartDate = Get-Date
 Write-Host -ForegroundColor White "------------------------------------"
 Write-Host -ForegroundColor White "| Update the Page Layouts of the Existing Pages |"
 Write-Host -ForegroundColor White "| Started on: $StartDate |"
 Write-Host -ForegroundColor White "------------------------------------"
 
 $LogTime = Get-Date -Format yyyy-MM-dd_hh-mm
 $LogFile = ".UpdatePageLayout-$LogTime.rtf"
 
 #start-transcript $logfile
 
 $scriptBase = split-path $SCRIPT:MyInvocation.MyCommand.Path -parent
 Set-Location $scriptBase
 
 $ErrorActionPreference = "Stop"
 
 function AddPowerShellSnapin()
 {
     try
     {
         Write-Host "Adding PowerShell Snap-in" -ForegroundColor Green
         # Try to get the PowerShell Snappin.  If not, then adding the PowerShell snappin on the Catch Block
         Get-PSSnapin "Microsoft.SharePoint.PowerShell" 
     }
     catch
     {
         if($Error[0].Exception.Message.Contains("No Windows PowerShell snap-ins matching the pattern 'Microsoft.SharePoint.PowerShell' were found"))
         {
             Add-PSSnapin "Microsoft.SharePoint.PowerShell"
         }
     }
     Write-Host "Finished Adding PowerShell Snap-in" -ForegroundColor Green
 }
 
 
 function UpdatePageLayout([string]$WebURL, [string]$PageLayoutName,[string]$PublishingPageName)
 {
     #Get the web and page
     $Web = Get-SPWeb $WebURL
     
     #Get Publishing Site and Web
     $PublishingSite = New-Object Microsoft.SharePoint.Publishing.PublishingSite($Web.Site)
     $PublishingWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($web)
  
     #Get New Page Layout
     $SitePageLayouts = $PublishingSite.GetPageLayouts($false)
     $NewPageLayout = $SitePageLayouts | ? {$_.Name -eq $PageLayoutName}
 
     #Get Pages Library
     $PublishingPage = $PublishingWeb.GetPublishingPage($WebURL + "Pages/" + $PublishingPageName)  
     $PublishingPage.CheckOut()
     $PublishingPage.Layout = $NewPageLayout
     $PublishingPage.ListItem.Update();
     $PublishingPage.CheckIn("Page layout Updated via PowerShell")
     $PublishingPage.ListItem.File.Publish("Published via PowerShell")
     if ($PublishingPage.ListItem.ParentList.EnableModeration)
     {
         $PublishingPage.ListItem.File.Approve("Publishing Page Layout Updated!");
     }
  
     write-host "Updated Page layout on: "$PublishingPage.url -ForegroundColor Green
 }
  
 
  
 
  
  
  try
 {
     [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Sharepoint")
     [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Sharepoint.Administration")
         
     $ConfigXmlPath = $scriptBase + "ConfigXMLPageLayouts.Config.xml"
     Write-Host "Read the Config Values" -ForegroundColor Green 
     [Xml]$Config = Get-Content $ConfigXmlPath  
     
     AddPowerShellSnapin
     
     foreach($Page in $Config.Configuration.Pages.Page)     
     {
         UpdatePageLayout $Config.Configuration.PublishingSite.URL $Page.LayoutName $Page.Name
     }
 }
 catch
 {
     Write-Host "Custom Exception Happened on Main : " + $Error[0].Exception.Message -ForegroundColor Red  
 }
 

And the Config XML is as follows.

 <Configuration EnvironmentName="Dev">
   <PublishingSite URL="http://MySiteCollectionURL/" />
   <Pages>
 	<Page Name="home.aspx" LayoutName=" Home-Layout.aspx"></Page>
 	<Page Name="books.aspx" LayoutName="Topic-Layout.aspx"></Page>
   </Pages>
 </Configuration> 
 
 

 

 

Happy Coding,

Sathish Nadarajan.

Category : PowerShell, SharePoint

Author Info

Sathish Nadarajan
 
Solution Architect
 
Rate this article
 
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 15+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business ...read more
 

How to use a single PageLayout for View and Edit Mode in SharePoint 2013

Sathish Nadarajan
 
Solution Architect
April 1, 2015
 
Rate this article
 
Views
14283

In one of the older Article, we saw how to create a PageLayout using Visual Studio. A small add-on to that article is the one which we are going to see now.

I request the readers to read that article first and then reading this one is a worth. Moreover, here we are not going to discuss elaborately. Just a continuity of the older one as recently I met with this kind of requirement.

Basically a Layout which should be used for both the View and Edit Mode. The user will be editing the PublishingPageContent from this layout. As soon as they save the page, then the PublishingPageContent should be rendered on the same page.

For that, there is nothing much deviation from the older one. But the only thing is EditModePanel.

The aspx file would be something as below.

 <%@ 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="PlaceHolderAdditionalPageHead" runat="server">
 	<SharePointWebControls:CssRegistration name="<% $SPUrl:~sitecollection/Style Library/~language/Themable/Core Styles/pagelayouts15.css %>" runat="server"/>
 	<PublishingWebControls:EditModePanel runat="server">
 		<!-- Styles for edit mode only-->
 		<SharePointWebControls:CssRegistration name="<% $SPUrl:~sitecollection/Style Library/~language/Themable/Core Styles/editmode15.css %>"
 			After="<% $SPUrl:~sitecollection/Style Library/~language/Themable/Core Styles/pagelayouts15.css %>" runat="server"/>
 	</PublishingWebControls:EditModePanel>
 	<SharePointWebControls:FieldValue id="PageStylesField" FieldName="HeaderStyleDefinitions" runat="server"/>
 </asp:content>
 <asp:Content ContentPlaceHolderId="PlaceHolderPageTitle" runat="server">
 	<SharePointWebControls:FieldValue id="PageTitle" FieldName="Title" runat="server"/>
 </asp:Content>
 <asp:Content ContentPlaceHolderId="PlaceHolderPageTitleInTitleArea" runat="server">
 	<SharePointWebControls:FieldValue FieldName="Title" runat="server"/>
 </asp:Content>
 <asp:Content ContentPlaceHolderId="PlaceHolderTitleBreadcrumb" runat="server"> 
     <SharePointWebControls:ListSiteMapPath runat="server" SiteMapProviders="CurrentNavigationSwitchableProvider" RenderCurrentNodeAsLink="false" PathSeparator="" CssClass="s4-breadcrumb" NodeStyle-CssClass="s4-breadcrumbNode" CurrentNodeStyle-CssClass="s4-breadcrumbCurrentNode" RootNodeStyle-CssClass="s4-breadcrumbRootNode" NodeImageOffsetX=0 NodeImageOffsetY=289 NodeImageWidth=16 NodeImageHeight=16 NodeImageUrl="/_layouts/15/images/fgimg.png?rev=23" HideInteriorRootNodes="true" SkipLinkText="" />
 </asp:Content>
 <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
 	<div class="article article-body">
 		<PublishingWebControls:EditModePanel runat="server" CssClass="edit-mode-panel title-edit">
 			<SharePointWebControls:TextField runat="server" FieldName="Title"/>
 		</PublishingWebControls:EditModePanel>
 		<div class="article-content">
 			<PublishingWebControls:RichHtmlField FieldName="PublishingPageContent" HasInitialFocus="True" MinimumEditHeight="400px" runat="server"/>
 		</div>
 		
 	</div>   
 	 
 </asp:Content>
 

Happy Coding.

Sathish Nadarajan.

Author Info

Sathish Nadarajan
 
Solution Architect
 
Rate this article
 
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 15+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business ...read more
 

Add snippets in Page layout using design manager

Santhosh Babu
 
Technology Specialist
January 5, 2014
 
Rate this article
 
Views
29546

In this post I am going to add a Web Part Zone snippet in page layout.

Step 1: Open the site then click design manager link from right top corner "Settings" menu.

clip_image002

Step 2: Click “Edit Page Layouts” link

clip_image004

 

Step 3: Click “SamplePageLayout” .It will open preview page.

clip_image006

 

Step 4: Once open the preview page then click Snippets menu from top right side. It will open “Snippet Gallery” in new tab page.

clip_image008

 

Step 5: Click the Web Part Zone menu item in “DESIGN “tab.

clip_image010

 

 

 

 

Step 6: In this page we can easy to configure component properties. Now, I will change the Web part Zone Title under Misc category. After customization must click the update button then only the changes are reflected in the component snippet.

clip_image012

Step 7: Once click the update button the HTML code automatically generated in the “HTML snippet” box and click “Copy to Clipboard” button.

clip_image014

 

Step 8: Open the mapped network drive then open the page layout HTML file and paste HTML snippet where you want the web part zone to show.

clip_image016

Step 9: We should add the HTML snippet inside of the <asp:ContentPlaceHolder ID="PlaceHolderMain" runat="server">. In my example I am remove all the default div tags (inside of the content place holder) and paste with my HTML Snippet content.

Default content

clip_image018

Replaced Content

 

clip_image020

Step 10: Once complete the activity the save the page and publish the page layout in design manager.

clip_image022

Step 11: Open the sample page (which we have used in “SamplePageLayout”) and click edit and try to “Add a Web Part”. You will see the web part zone title in the “Add part to” drop down.

clip_image024

clip_image026

 

Next Blog I will explain the create design manager master page package.

Happy Coding.

SanthoshBabu ManickaMohan

Author Info

Santhosh Babu
 
Technology Specialist
 
Rate this article
 
Working as a Technology Specialist in SharePoint ~ Cognizant ...read more
 

How to Create Page layout using design manager

Santhosh Babu
 
Technology Specialist
 
Rate this article
 
Views
16649

In this post I am going to create a page layout using design manager.

Step 1:

Open the site then click design manager link from right top corner "Settings" menu.

clip_image002

Step 2: Click “Edit Page Layouts” link

 

clip_image004

 

 

 

 

 

 

 

Step 3: Click “Create a page layout” link. It will open a popup window and select Master page (which we have created in earlier post) for this scenario we need to select “HTMLPage” then click ok button.

clip_image006

 

Step 4: Once the page layout created then publish the same.

clip_image008

 

 

 

 

Step 5: After publish the page layout click the “Settings” icon then click Add a Page. It will open a popup window and provide the page name and click create button.

clip_image010

clip_image012

 

Step 6: After created page automatically redirect to the new page.

clip_image014

 

Step 7: Select the PAGE tab and open Page Layout menu then select “SamplePageLayout”. It will change the page layout. After then check-in and publish the page.

 

clip_image016

 

 

 

clip_image018

 

Next Blog I will explain about how to add code snippet in page layout.

Happy Coding.

SanthoshBabu ManickaMohan

Author Info

Santhosh Babu
 
Technology Specialist
 
Rate this article
 
Working as a Technology Specialist in SharePoint ~ Cognizant ...read more
 

Create Publishing Page using Custom PageLayout by PowerShell in SharePoint 2013

Sathish Nadarajan
 
Solution Architect
December 11, 2013
 
Rate this article
 
Views
29323

I was come up with an interesting requirement stating that, we need to create some huge numbers of pages based on a Custom PageLayout in our Site Collection. For that, I was planning to write a PowerShell with some configuration values. So that, on the execution, the script will create those pages. Thought of sharing this to the community.

Basically it is going to be a simple straight forward script. We have a publishing portal and the custom PageLayout has been deployed on the Publishing Portal.

The script is self-explanatory and doesn’t require much explanation I guess.

 # Add the PowerShell Snapin
 $snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
 if ($snapin -eq $null) 
 { 
     Add-PSSnapin "Microsoft.SharePoint.Powershell" 
 }
 
 # Get the SiteURL
 $SiteUrl = "https://MySiteCollectionURL"
 
 # Get the WebURL
 $WebUrl = "https://MyWebURL"
 
 # Get the PageLayout
 $PageLayoutRelUrl = "/_catalogs/masterpage/CustomPageLayout.aspx"
 
 # Get the Page URL
 $PageName = "Test.aspx"
 
 # Get the Title of the Page which is going to get created
 $PageTitle = "Test"
 
 # Initialize the Site Object
 $Site = Get-SPSite($SiteUrl)
 
 # Get the Publishing Site based on the SPSite
 $PubSite = New-Object Microsoft.SharePoint.Publishing.PublishingSite($Site)
 
 # Get the SPWeb Object
 $Web = Get-SPWeb $WebUrl
 
 # Initialize the PublishingWeb based on the SPWeb
 $PubWeb = [Microsoft.SharePoint.Publishing.PublishingWeb]::GetPublishingWeb($Web)
  
 # Get the PageLayouts Installed on the Publishing Site
 $Layouts = $PubSite.GetPageLayouts($False)
 
 # Get our PageLayout
 $PageLayout = $Layouts[$PageLayoutRelUrl]
  
 # Create a new publishing page.
 $Page = $PubWeb.AddPublishingPage($PageName, $PageLayout)
 
 # Assign the Title for the Page
 $Page.Title = $PageTitle
 
 # Update the Page
 $Page.Update();
 
 # Check in the Page with Comments
 $Page.CheckIn("Test Comment")
 
 # Publish the Page With Comments
 $Page.ListItem.File.Publish("Test Publish Comment")
 

That’s it. Run the script with the required privilege. To verify that, go the Pages Library and make sure that you are seeing Test.aspx there.

Happy Coding.

Sathish Nadarajan.

Author Info

Sathish Nadarajan
 
Solution Architect
 
Rate this article
 
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 15+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business ...read more
 

How to Create a Page Layout (PageLayout) with ContentType in SharePoint 2013 using Design Manager – Part III

Sathish Nadarajan
 
Solution Architect
November 16, 2013
 
Rate this article
 
Views
41762

In this article, let us see how to create a PageLayout using Design Manager. In the previous article, we saw about the creating a page layout using Visual Studio, SharePoint Designer. Here let us utilize a new feature in SharePoint 2013, which is not available on SharePoint 2010 – Design manager.

Design Manager is a new feature which is available only in SharePoint 2013 (not in the previous flavors of SP), that allows us to easily create the branding artifacts like MasterPages, CSS, PageLayouts Etc.,

Design Manager will be available only in Publishing template and not in the Developer Site Template. Hence, we need to create a Publishing Site for this demo.

Let me create a publishing Site.

clip_image002

On the Settings Icon on the Right top corner, you can find a new link called Design Manager.

clip_image004

Design Manager will look like this.

clip_image006

Click on the Edit page Layouts link.

clip_image008

Click on the Create Page Layout.

clip_image010

Enter the name for the pagelayout and select the Content Type which we created.

clip_image011

Keep the master page as it is as of now. Since, we are not focusing that.

Now, we got the html file inside the pagelayouts folder.

clip_image013

Let us, publish this. Then the “Approval Status” will become “Approved”

clip_image015

Now, let us go to the Pages document library.

Associate this doc library into our Content Type which we created. To add our Content Type, follow the steps.

clip_image017

Go to Library Settings.

clip_image019

clip_image021clip_image023

That’s it. Now we added our Content Type.

To confirm that, go to the Files-> New Document. Our newly added content type will be listed there.

clip_image025

On the Create Page, you can find the Page Layout, which we created using the Design Manager.

clip_image027

Let me create a page based on the page layout we created.

After giving the mandatory fields, our page will look like the below.

clip_image029

Now, let us see, how to modify the layout of the Page Layout which we created. To see that, go to Master Page Gallery.

clip_image031

You can find the list of files, and the one which we created just now. For every PageLayout, created by the designer would be having 2 files. One aspx and one html. In our case, PageLayoutDesignmanager.aspx and PageLayoutDesignManager.html.

As far as concerning the Design manager approach, html file is very important. The aspx page will be overridden by html template when next time, sharepoint gets loaded. Hence, it is strongly recommended that not to modify the aspx. Modify only the html.

Being a developer/designer, we can use any tool to modify the html. To do that, we need to map the galleries into our local computer.

Open the Windows Explorer and Select Map Network Drive.

clip_image033

Enter the folder as the url of the masterpages gallery.

clip_image035

Now, the folder would be mapped to our local machine.

We can see the files, which we were talking about.

clip_image036

Now, open the html in your favourite editor and modify the layout. Let me open it using the visual studio itself.

The page is a mixture of pure html code and commented aspx

clip_image038

For instance in the html file, remove the following selection that displays the Title field in the Page Title:

clip_image040

As soon as you do it, the modification will be reflected in the associated aspx page:

clip_image042

Now, let’s create a new Page Content from our new JobPosting page and you will see that everything works as expected.

When saved, the page looks like this:

clip_image044

There are no fields labels.

So update the html file with the following spans :

clip_image046

When you make any modification to the html file, don’t forget to Publish a Major version of the file (in the Master Page and Page Layouts gallery).

clip_image048

Now, we are going to redeploy the package.

Go to Design manager and Select Create Design Package.

clip_image050

clip_image052

On clicking the Create,

clip_image054

By clicking the download, we can download our package.

The downloaded will be a WSP and we can open the WSP using visual studio and see, the artifacts. Then we need to copy those files and put in a separate visual studio solution to deliver the package alone.

Happy coding.

Sathish Nadarajan.

Author Info

Sathish Nadarajan
 
Solution Architect
 
Rate this article
 
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 15+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business ...read more
 

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

Sathish Nadarajan
 
Solution Architect
 
Rate this article
 
Views
29602

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.

Author Info

Sathish Nadarajan
 
Solution Architect
 
Rate this article
 
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 15+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business ...read more
 

Leave a comment