0

I created a search-center and want to apply a custom masterpage to it. I want to deploy the masterpage using a module and the feature of my solution. I created a module and the Elements.xml looks like

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <Module Name="SearchcenterModule" Url="Suche/_catalogs/masterpage">
       <File Path="SearchcenterModule\minimal.master" Url="minimal.master" />
    </Module>
</Elements>

On activating my feature in the site-collection-features I get an error

(null) "Suche" not found.
...

where "Suche" is the Name of my subsite, i.e. : http://mysharepoint/Suche

Of course I can add the file manually but there must be a way to deploy it using the feature-activation.

Thank you for your help.

2

I don't know the solution but, have you tried to set feature scope to web, use default module definition and activation of this module on the Suche subsite?

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="MasterPageModule" Url="_catalogs/masterpage">
    <File Url="MasterPage.master" Type="GhostableInLibrary" IgnoreIfAlreadyExists="False" />
  </Module>
</Elements>

If it doesn't work, have you tried to use ~Site token?

<Module Name="SearchcenterModule" Url="~Site/_catalogs/masterpage">
  • Thank you for your repsonse. I need to have the feature scope at "Site" so all actual subsites can access the masterpages. With a SearchCenter it is different, though. The "~Site"-token gives me an error "Can't create Page ~Site". – bash.d Jun 26 '13 at 9:22
  • If I'm not wrong you can store master page into catalogs of root web and reuse it on a subsite. All that you need to activate publishing feature and set master page from site settings. It works for SharePoint Server, not for foundation. – Alexander Jun 26 '13 at 10:43
  • Do I have to set this under SiteCollection Features or in the Central Administration? – bash.d Jun 26 '13 at 11:18
  • Indeed, you are right!!! It worked!!! – bash.d Jun 26 '13 at 11:21
2

Masterpages and pagelayout can only be deployed to SiteCollections, not sites/subsites.

So your feature needs to be Site scoped. You can always in your FeatureReceiver set the masterpage on a specific SPWeb.

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

IgnoreIfAlreadyExists makes sure you overwrite it when you deploy so new changes appear. Type="GhostableInLibrary" makes sure the new masterpage/pagelayout is visible in the Masterpage & Pagelayouts gallery.

  • Thank you for your response. I cannot access the masterpages from a SearchCenter. So, all I can do is to override the masterpage (in my case minimal.master) manually? – bash.d Jun 26 '13 at 9:24
  • As I mentioned in my answer you can add a FeatureReceiver to your feature and in that you can programmatically set the masterpage eg. your SearchCenter. – user2536 Jun 26 '13 at 9:59

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.