Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I've Sharepoint 2010 Server and I have a main site, say, in http://mysharepoint.com.

I've edited its master page (v4.master) (to add some web parts, yes, web parts directly into the master page, it's possible) and now I want those web parts to be visible in new sub-sites I create, say http://mysharepoint.com/site1. So basically I need the new sites to inherit the master page from the main one.

Is this possible?

Thank you

share|improve this question
add comment

2 Answers 2

up vote 6 down vote accepted

First of all, never, ever modify v4.master. That is a Microsoft page and will likely be replaced/updated in a future service pack and then poof, there goes your master page :) Create a copy of it and use that instead.

If you put the web parts in the standard web part zones in the master page, all new pages that do not have content defined for those zones should use the web parts automatically.

share|improve this answer
    
Thank you, you're right, I should not be modifying v4.master (Sharepoint newbie here =P). Anyway, I'm not sure which is the standard web part zones in the master page. I'm adding them in the left bar (above the Document Libraries box) because of client request. Can you provide further details? Thank you –  emzero May 6 '11 at 20:33
    
This is normally the sort of thing that would actually be done in a Page Layout rather than the master Page. However, the master page makes it pretty clear on which zones go where. You may also need to view the source of the Page Layouts that you are using on your site to be 100% certain of the proper zones. –  Dave Wise May 6 '11 at 20:38
    
I know that this should be done in page layouts instead of master page. We decided to put the webparts on the master page because we need to be available in the whole site... or there's another way of having a web part all over the site without altering the master page? –  emzero May 6 '11 at 20:59
    
this is a bit more complex, but you could always write a feature that populates all of the WebPart zones on all of the existing pages when the feature is activated. –  Dave Wise May 7 '11 at 14:29
    
@emzero, listen Dave's advice regarding the v4.master, man knows what he's talking about :-) –  Brian Scott Dec 14 '12 at 11:03
add comment

I would recommend implementing your functionality as User Controls, rather than as Web Parts, and building that into the master page.

If you have to use Web Parts, then build those into the Site Templates you're using to create your subsites.

Failing that, you're into the realms of writing a feature to populate the web part zone. That's possible, but can be unreliable if you're also using the publishing features, I've found.

To apply the master page to subsites, I would create a Feature with a Feature Receiver that sets the subsite's master pages. Note:

  • Sites actually can have two master pages
  • Meeting sites use a different master page to other sites

This is for 2007, but the same is true in 2010

http://www.novolocus.com/2008/10/30/feature-receiver-to-apply-master-pages/

I would then use feature stapling to active that feature receiver when the new site is created.

share|improve this answer
    
I'm using the VS template 'Visual Web Part' which already includes the logic to use User Controls. –  emzero May 9 '11 at 19:50
1  
Yes, but I'm saying put it into the master page, not into the web part. The advantage of web parts is their easy configurability within for site admins, or users who're personalizing their page. This is kind of contradictory with making changes to the master page, which should be the same, well, everywhere (unless override). –  Andy Burns May 10 '11 at 9:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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