开发者

SharePoint 2010: custom masterpage for programmatically created subsites

What’s the best way to add a custom masterpage to a subsite that is being created programmatically in a feature event receiver? Each of these 50 subsites gets its own “_catalogs/masterpage”, so I have a feeling that Elements.xml for the root-site’s Module/Elements.xml is out. Mor开发者_运维问答e feature receiver code? PowerShell post-deployment processing?


Is this going to be 50 copies of the same Master Page?

If not, I can't really picture how the Master Page will be specially made using code, but also a Feature Module element is certainly out.

But if it is 50 copies of the same file, you could deploy the Master Page to the Gallery one time using a Feature Module element. Then in your Feature Receiver, make a copy of that file with a new name in the Master Page Gallery and attach it to your website:

web.MasterUrl = "_catalogs/masterpage/custom_v4.master";
web.CustomMasterUrl = "_catalogs/masterpage/custom_v4.master";
web.Update();


You might want to think about creating custom site definition.


You have following choices to set master page for the site: 1) Using Sharepoint Browser UI (from Site Settings page) 2) Using Custom site definitions 3) Programmatically 4) Using SharePoint Designer

Looking at your scenario, no 3 is an option. You may want to do it in the Feature Receiver itself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜