I have created my custom master page. But i don't want to display it in Site Master Page and System Master Page dropdown in Site Master Page Settings.
How can i do this programmatically?
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communitySo,Finally i got the answer. To solve this issue you have to make changes in element.xml file.
<File Path="MasterPageGalleryModule\xyz.master" Url="xyz.Configuration.master" Type="GhostableInLibrary">
<Property Name="Title" Value="xyz Masterpage" />
<Property Name="UIVersion" Value="15" />
<Property Name="ContentType" Value="$Resources:cmscore,contenttype_masterpage_name;" />
**<Property Name="PublishingHidden" Value="TRUE" />**
</File>
To hide master page you have to add new property i.e. PublishingHidden and set its value "TRUE".
Make sure that Publishing feature should be activated for particular sitecollection before deployment.
There is no way to hide published Master Pages from Site/System master page dropdown. One way is that you unpublished your master page so it wont be visible. Or as a workaround, you can write some JS code into your current master page and hide/delete the dropdown option from the select input box.
Edit
I also figured out that in master page gallery, you have the option to hide a page. Just navigate to Master Page Gallery
, select you desired Master Page (or HTML page if it is linked)
. Click on Files
in ribbon, now under manage section click on Edit Properties
. This will open the edit form and show a boolean field named has Hidden Page
, check the field and save the form. The master page will no longer visible in site/system master page dropdown.