Page layouts included in a SharePoint solution require additional data to be added to their library properties to associate them with the page layout content type. In this recipe, we will include a copy of the BlankWebPartPage.aspx
page layout that we have renamed Tacoma_BlankWebPartPage.aspx
with the appropriate properties. You can download a copy of BlankWebPartPage.aspx
from the web interface or with SharePoint Designer.
Follow these steps to include a page layout in the solution:
PageLayouts
).Sample.txt
file in the PageLayouts
module.PageLayouts
module.Tacoma_BlankWebPartPage.aspx
page layout from your filesystem.PageLayouts
module, open the Elements.xml
file.<Module>
element, set the Url
property to _catalogs/masterpage
, the Path
property to null, and the RootWebOnly
property to FALSE
.<Module Name="PageLayouts" Url="_catalogs/masterpage" Path="" RootWebOnly="FALSE">
<File>
element, set the Type
property to GhostableInLibrary
, the IgnoreIfAlreadyExists
property to TRUE
, and the Url
property to Tacoma_BlankWebPartPage.aspx
.<File>
element, add the properties that will be assigned to the file in the SharePoint library.<File Path="PageLayoutsTacoma_BlankWebPartPage.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" Url="Tacoma_BlankWebPartPage.aspx"> <Property Name="Title" Value="$Resources:Code6587ENCh04,Tacoma_PageLayout_Name;" /> <Property Name="Description" Value="$Resources:Code6587ENCh04,Tacoma_PageLayout_Description;" /> <Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" /> <Property Name="PublishingAssociatedContentType" Value=";#$Resources:cmscore,contenttype_articlepage_name;;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D;#"/> </File>
Elements.xml
file. The following screenshot shows the contents of the Elements.xml
file:In addition to adding files to a SharePoint library, a module can also set the properties of the file in the library. In this recipe, we added a custom page layout to a module and set the properties of the file to provide it with a page layout title and associate it with the page layout content type.
The values of the Title
and Description
properties are resource strings that we will create in the Adding localization to a SharePoint solution recipe. The ContentType
property uses a resource string from SharePoint and the PublishingAssociatedContentType
property instructs SharePoint to make this file a page layout.
The /_catalog/masterpage
library, where master pages and page layouts are stored, contains multiple content types. If a page layout file is not associated with the page layout content type, it will not be available in the web interface when creating a new content page.
18.227.102.50