A common requirement of many MOSS projects has been creating some news or article pages with custom columns or additional columns.To achieve this, we need to first create a custom content type with the same columns.Refer to the post create-custom-columns-and-custom content type for the same.
Here we will show how to create a custom page layout and bind it to the custom content type to create a custom article/news page.
2.Create a Feature.xml in the MyCustomColumns folder.
<Feature Id="0EE75CE9-189E-4ddd-8E1D-433ACBEEA3A3"
Title="My News Article Page Layout"
Description="My News Article Page Layout with custom column added"
Version="1.0.0.0"
Scope="Site"
Hidden="FALSE"
ImageUrl="MySharepointProject\AfricanPith32.gif" xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="layoutfiles.xml"/>
<ElementFile
Location="PageLayouts\MyNewsArticle.aspx" />
</ElementManifests>
</Feature>
Title="My News Article Page Layout"
Description="My News Article Page Layout with custom column added"
Version="1.0.0.0"
Scope="Site"
Hidden="FALSE"
ImageUrl="MySharepointProject\AfricanPith32.gif" xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="layoutfiles.xml"/>
<ElementFile
Location="PageLayouts\MyNewsArticle.aspx" />
</ElementManifests>
</Feature>
3.Create layoutfiles.xml file at the same location.
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="PageLayoutsModule" Url="_catalogs/masterpage" Path="PageLayouts" RootWebOnly="True"> //Name: name of the module,URL:where the pagelayout will be uploaded,Path:relative path in project for pagelayout file
<File Url="MyNewsArticle.aspx" IgnoreIfAlreadyExists="TRUE" Type="GhostableInLibrary">
<Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;"/>
<Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/ArticleLinks.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/ArticleLinks.png"/>
<Property Name="PublishingAssociatedContentType" Value=";#MyNews Article Page;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D0039F449FD09F64ed283F86980FE51CF92;#"/>
</File>
</Module>
</Elements>
//Here are the properties corresponding to the above mentioned ones.
<Module Name="PageLayoutsModule" Url="_catalogs/masterpage" Path="PageLayouts" RootWebOnly="True"> //Name: name of the module,URL:where the pagelayout will be uploaded,Path:relative path in project for pagelayout file
<File Url="MyNewsArticle.aspx" IgnoreIfAlreadyExists="TRUE" Type="GhostableInLibrary">
<Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;"/>
<Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/ArticleLinks.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/ArticleLinks.png"/>
<Property Name="PublishingAssociatedContentType" Value=";#MyNews Article Page;#0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900242457EFB8B24247815D688C526CD44D0039F449FD09F64ed283F86980FE51CF92;#"/>
</File>
</Module>
</Elements>
//Here are the properties corresponding to the above mentioned ones.
Download any existing article page layout from the site and rename it to MyNewsArticle.aspx
Add the corresponding fields in the pagelayout where you want them to appear.(Use <tr><td> to place them in correct structure.) eg;
<SharePointWebControls:TextField runat="server" id="SourceText" FieldName="SourceText"/>
<SharePointWebControls:MultipleLookupField id="ArticleSubType" FieldName="ArticleSubType" runat="server" />
<SharePointWebControls:TextField runat="server" id="SourceText" FieldName="SourceText"/>
<SharePointWebControls:MultipleLookupField id="ArticleSubType" FieldName="ArticleSubType" runat="server" />
Add field controls here to bind custom metadata viewable and editable in edit mode only
<PublishingWebControls:editmodepanel runat="server" id="editmodepanel1">
<table cellpadding="10" cellspacing="0" align="center" class="editModePanel">
<tr><td>
<SharePointWebControls:NoteField runat="server" id="AbstractText" FieldName="AbstractText"/>
</td></tr></table>
</PublishingWebControls:editmodepanel>
Activate the feature,and you will find your pagelayout in the option when creating a new page.You can create a page with this pagelayout which will be saved in pages library as Article page with custom columns.
