Tuesday, March 1, 2011

Create custom page layout using Feature

If you want to create a custom page layout using features in your solution, use the below steps-

Create a folder structure as -

12----
Template---
Features------
ABCPageLayout---
layout.aspx
Feature.xml
Elements.xml

layout.aspx-----------------------------

First create the entire layout in sharepoint designer and copy paste into .net aspx file.


Feature.xml-----------------------------

Feature Id="8C463F26-AE3C-4309-A284-AC095EB351A9"
Title="ABCPageLayout"
Description="page layoutt for use"
Version="12.0.0.0"
Scope="Site"
Hidden="True"
DefaultResourceFile="core"
xmlns="http://schemas.microsoft.com/sharepoint/"
ElementManifests
ElementManifest Location="ProvisionedFiles.xml"/
/ElementManifests
/Feature

Elements.xml---------------------------------

Module Name="OSGPageLayouts" Url="_catalogs/masterpage" Path="PageLayout" RootWebOnly="TRUE"
File Url="ABCPageLayout.aspx" Type="GhostableInLibrary"
Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" /
Property Name="PublishingAssociatedContentType" Value=";#$Resources:cmscore,contenttype_articlepage_name;;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D;#"/
/File


Deploy this as a feature and your page layout will automatically go to the sharpoint pagelayouts.

2 comments:

  1. Hi!! Swati, its an knowledgeable post , i appreciate your efforts for makin it simple and understandable.I have a small query , would appreciate if you could elaborate the use of
    Property Name="ContentType" Value=""
    and again with Property Name="
    PublishingAssociatedContentType" and how we are getting the value in Elemnt.XML

    ReplyDelete
  2. Hi Aakash,

    Thanks for your comment. Basically in element.xml, we have a module section, then a file section and then two property sections. The less than and greater than signs do not appear in this blog. but, these two property's are two different sections. put less than and greater than signs in your xml.

    Thanks,
    Swati

    ReplyDelete