Sharepoint - Add web part zone in custom page layout
SharePoint 2013
In 2013 you can use design manager for generating web-part zone snippet.
- To insert a Web Part zone snippet
- Browse to your publishing site.
- In the upper-right corner of the page, choose the Settings gear, and then choose Design Manager.
- In Design Manager, in the left navigation pane, choose Edit Page Layouts.
- Select the name of the page layout that you want to add the snippet to.
- To open the Snippet Gallery, choose Snippets in the upper-right corner of the server-side preview.
- On the ribbon, on the Design tab, choose Web Part zone.
- On the right side of the Snippet Gallery, under About this Component, click or select section headers to expand or collapse groups of properties, and then configure any custom settings that you want.
- After you configure any properties, choose Update. This updates the HTML snippet on the left side of the page, so that the markup reflects your custom settings. You can always choose Reset to return all properties to their default settings.
- On the left side of the Snippet Gallery, under HTML Snippet, choose Copy to Clipboard.
- In your HTML editor, open the mapped network drive on your computer, and then open the HTML file for the master page or page layout that you're adding the snippet to.
- In the HTML file, paste the snippet where you want the markup to appear.
- Replace the
<div>
whereclass="DefaultContentBlock"
with your own specific content. - If you want to prepopulate the zone with Web Parts—for example, if the zone will restrict content authors to modifying only existing Web Parts and not adding new ones—insert Web Part snippets where the
<!--DC … -->
tag appears. - Save the page, and then refresh the server-side preview in Design Manager to make sure the page appears as expected.
http://msdn.microsoft.com/en-us/library/office/jj862341(v=office.15).aspx
Design Manager generates snippet in following format
<div data-name="WebPartZone">
<!--CS: Start Web Part Zone Snippet-->
<!--SPM:<%@Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"%>-->
<div xmlns:ie="ie">
<!--MS:<WebPartPages:WebPartZone runat="server" ID="x0e5f5212505f48a9aac43df13eeae4f9" AllowCustomization="True" AllowPersonalization="False" FrameType="TitleBarOnly" LockLayout="True" Orientation="Vertical">-->
<!--MS:<ZoneTemplate>-->
<!--DC: Replace this comment with default web parts for new pages. -->
<!--ME:</ZoneTemplate>-->
<!--ME:</WebPartPages:WebPartZone>-->
</div>
<!--CE: End Web Part Zone Snippet-->
</div>
You can copy this into Page Layout (html) file.
SharePoint 2010
- Open the page layout in SharePoint Designer
- Place cursor inside the div where you want to place the webpart zone
- From Menu, Select Insert -> Web Part Zone
- Save and Publish the Page Layout
Add the following snippet:
<WebPartPages:WebPartZone runat="server" Title="TestZone1" ID="TestZone1">
<ZoneTemplate></ZoneTemplate>
</WebPartPages:WebPartZone>
It works.