Quantcast
Channel: Real SharePoint
Viewing all articles
Browse latest Browse all 11

Create Publishing Page via Feature

$
0
0

Following are steps for creating Publishing Page Via Feature

1. Create New Feature in SharePoint

2. Modify Feature.xml as below code

<?xml version="1.0" encoding="utf-8" ?>
<Feature  Id="{E51F42D4-9E43-4c43-B3DC-3F6F1CBE9D30}"
          Title="Create Custom Pages"
          Description="This feature will deploy custom pages in Pages Library"
          Version="1.0.0.0"
          Scope="Site"
	        Hidden="FALSE"
          xmlns="http://schemas.microsoft.com/sharepoint/">
  
  <ElementManifests >
    <ElementManifest Location="elements.xml" />
    <ElementFile Location ="CustomTemplate.aspx"/>
  </ElementManifests>   
</Feature>
3. Create New Elements.xml and modify code as mentioned below
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="Pages" Url="Pages">
    <File Name="MyPage.aspx" Url="MyPage.aspx"
      Path="CustomTemplate.aspx" Type="GhostableInLibrary"
      IgnoreIfAlreadyExists="TRUE">
      <Property Name="Title" Value="Custom Page Create by Feature"/>
      <Property Name="PublishingPageLayout"
        Value="~SiteCollection/_catalogs/masterpage/PageLayoutName.aspx"/>
      <Property Name="ContentType" Value="Content Type Name" />
      <Property Name="ContentTypeId" Value="Content Type ID" />
      <Property Name="Comments" Value="The resource or file that you have requested is not available. Please use the navigation at the top of this page to navigate the site." />
    </File>
  </Module>
</Elements>
4. Provide Content Type Name, Content Type ID and PageLayout Name
5. Create 1 Custom page with same Pagelayout manually in Pages Libaray
6. Goto Pages Library and Download the copy of the Page
7. Use that Page as template and place that page in feature folder, and update the template name in above strike through text 
Done !!!
Happy Coding !!!!


Viewing all articles
Browse latest Browse all 11

Trending Articles