In a publishing environment we often create custom page layouts based on our own content types, and of course if we are also creating custom site definitions, we’ll probably want to create pages in the site defs which are based on our custom page laouts – how do we do this?
Again, it’s all done using a CAML module element as shown below;
<Module Name="PublishingHomePage" Url="$Resources:cmscore,List_Pages_UrlName;" Path=""> <File Url="Default.aspx" Type="GhostableInLibrary"> <Property Name="Title" Value="Hom" /> <Property Name="ContentType" Value="My Location Page" /> <Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/MyLocationPage.aspx, My Location Page Layout" /> <Property Name="PublishingPageContent" Value="Welcome to the Publishing Site" /> </File> </Module>
The Property elements are used to set the column values of the new listitem which is created in the Pages library for this page.
- Title – The page title, this is what is usually displayed at the top of the browser window
- ContentType – the listitems contentype (name), which should be the content type used as the basis of the page layout
- PublishingPageLayout – this is the important one, this tells SharePoint what page layout to associate with the listitem (page), it has a very specific format and a gotcha (see below)
- PublishingPageImage, PublishingPageContent etc – you can populate any other columns here.
The PublishingPageLayout property format is;
{the url of the page layout}, {the title value of the page layout}
The gotcha is in the use of the comma (,); either don’t use it and just specify the url of the page layout, or, if you do use it make sure you leave a space character after the comma.
The title value specified after the comma is displayed in the “Page Layout” column in the Pages library.
awesome.