I have created a custom page layout which is based on Welcome Page Content Type. When I add it to first page of a Publishing Site, it still shows the default text (information) which was there before changing page layout. As soon as I add a web part zone to it, it shows the default text. When I remove the web part zones and deploy and add it to a page it is empty. How do I can add web part zone to my page layout and make it empty? thanks
2 Answers
Make sure that you're provisioned page layout is not unghosted (= customized) and only deployed through a WSP using a module referencing it as default text / unchanging page layouts are more than often the symptom of a customized file (SharePoint designer anyone ?) eg:
<Module Name="PageLayouts" Url="_catalogs/masterpage" Path="PageLayouts" RootWebOnly="TRUE">
<File Url="your-custom-page-layout.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE">
<Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
<Property Name="Title" Value="Your page layout title" />
<Property Name="MasterPageDescription" Value="..." />
<Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/WelcomeSplash.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/WelcomeSplash.png"/>
</File>
GhostableInLibrary is the key to have your fill relying on its initial definition in the 12/14/15 hive.
Within your page layout, any webpart zone will be consumed and used as defined.
eg (see at top & bottom, the 2 custom WPZ defined):
<%@ Page language="C#" Inherits="APB.SharePoint.Core.UI.PageLayouts.PageLayoutBase,APB.SharePoint.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0e9e449d7f998c48" %>
<%@ Register Tagprefix="sp" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="sp" Namespace="Microsoft.SharePoint.Publishing.WebControls" Assembly="Microsoft.SharePoint.Publishing, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="sp" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<asp:Content ContentPlaceholderID="PlaceHolderPageTitle" runat="server"><sp:FieldValue FieldName="Title" runat="server"/></asp:Content>
<asp:Content ContentPlaceholderID="PlaceHolderPageTitleInTitleArea" runat="server"><sp:FieldValue FieldName="Title" runat="server"/></asp:Content>
<asp:Content ContentPlaceholderID="PlaceHolderMain" runat="server">
<sp:WebPartZone runat="server" NoTableWrapping="true" AllowPersonalization="false" ID="WebPartZoneHeader" PartChromeType="None" Title="WebParts Zone Header" Orientation="Vertical" />
<%-- Display Mode ============================================================================================== --%>
<sp:EditModePanel runat="server" PageDisplayMode="Display">
<h2><sp:FieldValue runat="server" FieldName="Title" EnableViewState="False"/></h2>
<sp:FieldValue runat="server" FieldName="PublishingPageContent" EnableViewState="False"/>
</sp:EditModePanel>
<%-- /Display Mode ============================================================================================= --%>
<%-- Authoring Mode ============================================================================================ --%>
<sp:EditModePanel runat="server">
<h3>Page Content:</h3>
<sp:TextField runat="server" FieldName="Title"/>
<sp:RichHtmlField FieldName="PublishingPageContent" InputFieldLabel="Main Content" HasInitialFocus="True" MinimumEditHeight="400px" runat="server"/>
</sp:EditModePanel>
<%-- /Authoring Mode =========================================================================================== --%>
<sp:WebPartZone runat="server" NoTableWrapping="true" AllowPersonalization="false" ID="WebPartZoneFooter" PartChromeType="None" Title="WebParts Zone Footer" Orientation="Vertical" />
</asp:Content>
The page layout is for SharePoint 2013 but you can easily change the reference for 2010. it's just given as demonstration of having a custom webpart zone within a custom page layout.
-
What I meant was why when I change the page layout the site still shows the old content. It gets new layout but still shows old content (the default content when you create a publishing page for example). the content are web parts why they are there even when you change the page layout. I have now found out that it because the site definition of the site has a feature which adds these web parts, so it does not depend on the page layout.– MedesCommented Feb 14, 2013 at 8:08
-
1Thanks for the follow up, also, any field will be retained across page layout changes so if your content type A has field F1 and F2 and your content type B has field F1, F3 you'll retain the information from F1 when changing page layout (at the end, all list item are stored within one table with all fields declared...) Commented Feb 14, 2013 at 12:43
Can you please check if you have mapped the ContentPlaceHolders correctly.
The names of the ContentPlaceHolders in the page layouts should map to the relevant placeholder in the master page.