As SharePoint customization is pretty much about creating custom page layouts, I think is a good point to discuss about how to create a custom web part page. For this a SharePoint Designer is the only tool you need, except the situation you need to package the solution to deliver to customers.
Create custom master page
Open the site in SharePoint Designer, navigate to _catalogs/masterpage folder and go to File – Blank Master Page menu item option. You will be prompted to specify the name of your master page, in my case being named “sitecustom.master”. Once you save the file, open “minimal.master” and copy all the code into new created master. This will assure a minimum functionality for page layout which derived from it. As an easier alternative, you can read this MSDN article about how to create from interface a minimal master page.
Create page layout
In the same folder, go to File – ASPX menu item option. This way, you will create a simple ASPX web form page, not linked yet to the master. You can delete entire code and add the following declarations (page directives).
<%@ Page Language="C#" MasterPageFile="~site/_catalogs/masterpage/sitecustom.master" inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=220.127.116.11, Culture=neutral, PublicKeyToken=71e9bce111e9429c" meta:progid="SharePoint.WebPartPage.Document" meta:webpartpageexpansion="full" %> <%@ Register tagprefix="SharePoint" namespace="Microsoft.SharePoint.WebControls" assembly="Microsoft.SharePoint, Version=18.104.22.168, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Register tagprefix="WebPartPages" namespace="Microsoft.SharePoint.WebPartPages" assembly="Microsoft.SharePoint, Version=22.214.171.124, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
Version number can be different as is dependent by SharePoint version you are using. Mine is SharePoint Online and represents the latest version available.
You have successfully linked content page to master. However, an easier way is to select from File ribbon menu “New from master page” option. This should do the same thing, but if you choose this way, please be sure you have all required page directives.
Now your page is almost ready, but is still not editable because no web part zone is placed inside. Let’s do this and place web part zone inside “PlaceHolderMain” content placeholder.
<asp:Content ContentPlaceHolderID="PlaceHolderMain" runat="server"> <WebPartPages:WebPartZone runat="server" Title="Zone 2" ID="CentralZone"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone> </asp:Content>
You can create other content placeholders as well and populate them with web part zone. Is up to you here and you have freedom to customize everything. Just a small note from my side. If you are working in SharePoint Online or 2013, do not remove the tag below. It seems somehow is affecting edit panel for web part, making them not to be visible when you want edit something. Not sure why and what is happening there, but you better trust me.
<SharePoint:AjaxDelta id="DeltaPlaceHolderMain" IsMainContent="true" runat="server"> </SharePoint:AjaxDelta>
Associate page with content type
The last phase is to associate the page to a content type to allow creation of the pages using built-in functionality. To do this, you need to edit the properties of the page. You can be automatically directed to edit page from SharePoint Designer by clicking on the page in explorer view and choosing “Manage all file properties in the browser” option.
This being done, you need to make this page a page layout and give a value for associated content type. Below is my example.
Once you have done this, you need to test if functionality is correct. Just navigate to Page library, go to New Document menu option and select Web Page. On the next screen you should see the page you have just created available in the options list. Choose it and check if everything is working.
Here is a very basic example about how to create a custom layout for web part pages, but I will cover complex scenarios in the next posts. But until next posts, I wish you “Happy Coding!”. 🙂