Reputation: 5621
I'm able to successfully deploy a custom page layout and see it in the masterpage gallery. I can also manually create pages from this layout.
What I want to do is have a page in my site definition based on the custom layout deploy automatically with the package.
How do I deploy a page and tell that page which layout to use?
Upvotes: 3
Views: 5576
Reputation: 3558
using module you can create Page instance from your PageLayout
I guess your PageLayouts PageName is Home.aspx
than instance name should be Home.aspx
hope your Pagelayouts upload on _catalogs/masterpage
directory.
<Module Name="PagesLayouts"
Url="_catalogs/masterpage"
Path=""
RootWebOnly="False">
<File Url="YourModuleName/Home.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE"></File>
</Module>
than:
<Module Name="CustomPages" Url="Pages" Path="" RootWebOnly="FALSE">
<File Name="Home.aspx" Url="Home.aspx" Type="GhostableInLibrary" Path="Home.aspx" IgnoreIfAlreadyExists="TRUE">
<Property Name="Title" Value="Home" />
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/Home.aspx" />
<Property Name="ContentType" Value="Page" />
</File>
</Module>
see here : http://kamilmka.wordpress.com/2011/03/30/create-sharepoint-page-instance-from-a-feature/
i have just create demo project for understand properly. you can see my solution structure. just added one module name is PageLayouts and put one PageLayout Page.
full Element.xml file of Module i have used :
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="PageLayouts" Url="_catalogs/masterpage" Path="" RootWebOnly="TRUE">
<File Path="PageLayouts\CustomPageLayouts.aspx" Url="CustomPageLayouts.aspx" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE">
<Property Name="Title" Value="Custom General Page" />
<Property Name="MasterPageDescription" Value="Custom General page layout" />
<Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
<Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/WelcomeSplash.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/WelcomeSplash.png" />
<Property Name="PublishingAssociatedContentType" Value=";#$Resources:cmscore,contenttype_welcomepage_name;;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF390064DEA0F50FC8C147B0B6EA0636C4A7D4;#" />
</File>
</Module>
<!--Create Page instance from Page layouts of CustomPageLayouts.aspx-->
<Module Name="CustomPages" Url="Pages" Path="" RootWebOnly="FALSE">
<File Name="Home.aspx" Url="Home.aspx" Type="GhostableInLibrary" Path="PageLayouts\CustomPageLayouts.aspx" IgnoreIfAlreadyExists="TRUE">
<Property Name="Title" Value="Home" />
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/CustomPageLayouts.aspx"/>
<Property Name="ContentType" Value="Page" />
</File>
</Module>
Hope it helps!!
Upvotes: 5