Hello Friends,
Let us talk about today how to apply custom master page via Feature Files.
Here is an example of Element.xml and Feature.xml Files by which we can apply custom master page to Sharepoint Site through feature.
Explanation Of Feature.xml and Elements.xml:
--> The Feature element contains an ElementManifests element.ElementManifest references a file named elements.xml that contains the CAML to define elements for a new .master page file. There is also a Module element used to copy TeamCustom.master into the Sharepoint site under _catalogs/masterpages.The ElementManifest element is an essential part of the Feature definition because it references elements.xml.
Elements.xml
<?xml version="1.0" encoding="utf-8" ?>
<xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="AddMasters" List="116" Url="_catalogs/MasterPage">
<File Url="TeamCustom.Master" Path="MasterPage/TeamCustom.Master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="True">
<Property Name="ContentType" Value="$Resources:cmscore,contenttype_masterpage_name;" />
</File>
</Module>
</Elements>
Feature.xml
<?xml version="1.0" encoding="utf-8"?>
<xmlns="http://schemas.microsoft.com/sharepoint/">
<Feature Id="54F2CEA7-29D9-43e7-AB48-E4347E981E6A" Title="GaDOE.LookAndFeel"
Description="MasterPages and Page Layouts" Version="1.0.0.0" Hidden="FALSE"
Scope="Site" DefaultResourceFile="core" />
<ElementManifests>
<ElementManifest Location="elements.xml"/>
<ElementFile Location="MasterPage/TeamCustom.Master"/>
</ElementManifests>
</Feature>
Enjoy Sharepoint Branding with the master pages!!!
Disha Shah