0

I'm trying to create a site definition that uses a custom master page. I created a module in VS, called MasterPages, in which there are two folders (one inside another): _catalogs, masterpage. Within this folder i put my custom master page, socialfeed.master.

This is my Elements.xml Module configuration:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="MasterPages" RootWebOnly="TRUE" Url="_catalogs/masterpage">
    <File Path="MasterPages\_catalogs\masterpage\socialFeed.master" Url="socialFeed.master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE" />
  </Module>
</Elements>

And this is how i bind my custom master page on my site definition's default page:

<%@ Page language="C#" MasterPageFile="~/_catalogs/masterpage/socialfeed.master" 

I can actually deploy the solution without any problems but when i try create and access a new subsite based on that definition i get an error:

Error=The file /_catalogs/masterpage/socialfeed.master does not exist.  

Could you please help me understand where is the problem?

0

Your site is getting created so please open the site using SharePoint Designer and check if you can see the master page in the Master Pages libary. Each subsite has its own master page gallery. Copy the master page to that library and your site page should load fine.

  • The problem is i'm developing a site definition, so it should load the custom master page automatically, for every subsite created. – Dyd666 Oct 13 '15 at 16:40
  • try removing the folders inside the module and add the masterpage directly under the module. You might need to remove the rootweb only attribute from the module tag. Then in your site def you can activate the feature that contains your master page or you can use WebProvisioned event receiver to set the master page whenever a new web is created. This link may be helpful:blogs.msdn.com/b/bobgerman/archive/2011/01/31/… – HarryB Oct 13 '15 at 23:03
  • Thanks :) So, do i need to activate the master page using an event receiver? Because on the official MSDN walkthrough it doesn't say anything about feature activation: msdn.microsoft.com/en-us/library/vstudio/… – Dyd666 Oct 14 '15 at 8:32
  • you can either use feature stapling in your site definition or event receivers. have a look here sharepointnutsandbolts.com/2007/05/feature-stapling.html if you use feature stapling you wouldn't need to write any code. First make sure that your master page is getting deployed to the master page gallery. – HarryB Oct 14 '15 at 10:03
  • I checked, my master page has been deployed correctly. Here's the path: 15\TEMPLATE\FEATURES\SocialFeed_DeployMasterPage\MasterPages_catalogs\masterpage Still, it says not found when i try to reference it – Dyd666 Oct 21 '15 at 9:57
0

The URL of the master page you set in the module is actually socialFeed.master, not cernsocialfeed.master.

  • My bad, it was a typo on the question (fixed). Problem still remains. – Dyd666 Oct 13 '15 at 15:03
  • Can you check whether the masterpage file has been provisionned at the expected location? – Evariste Oct 13 '15 at 15:19
  • Deployment location of the custom mp/module is {SharePointRoot}\Template\Features\{FeatureName}\MasterPages_catalogs\masterpage\ but the masterpage is not there. – Dyd666 Oct 13 '15 at 15:22
  • Make sure to mark it as ElementFile in Visual Studio ( in the Properties of the file) – Robert Lindgren Oct 13 '15 at 15:27
  • Yep, it is marked as ElementFile – Dyd666 Oct 13 '15 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.