MySites with different master pages?
I have 1 web app with 3 site collections having different master pages...
Is this possible if user of site collection one go to their mysites then master page should be same of site collection 1
same for site collection 2 and 3.
Thanks in advance.
March 16th, 2012 4:11am
Hi AishaEME,
No matter how many site collections you have, there is only one MySite for all users.
My Site will have same Master page for all Site Collections.
Hope this helps!!
Thanks, Suraj Bangera | http://linkd.in/xXf8nk
Free Windows Admin Tool Kit Click here and download it now
March 17th, 2012 4:57am
HI,
Initially when the mysite is created it will be provisioned with a same master page.
However after provisioning it can be changed. However it will not be in the same way as a publishing site. You need to carry out some additional steps. I have written the following article that specifies changing the master page of a wiki site but same steps
can be used here.
http://social.technet.microsoft.com/wiki/contents/articles/4681.how-to-change-the-master-page-of-a-wiki-site-in-sharepoint-2007-en-us.aspx
I hope this will help you out.Thanks, Rahul Rashu
March 18th, 2012 10:18pm
HI,
Initially when the mysite is created it will be provisioned with a same master page.
However after provisioning it can be changed. However it will not be in the same way as a publishing site. You need to carry out some additional steps. I have written the following article that specifies changing the master page of a wiki site but same steps
can be used here.
http://social.technet.microsoft.com/wiki/contents/articles/4681.how-to-change-the-master-page-of-a-wiki-site-in-sharepoint-2007-en-us.aspx
I hope this will help you out.Thanks, Rahul Rashu
Free Windows Admin Tool Kit Click here and download it now
March 18th, 2012 10:18pm
True, the my site is created from the same template, and yes, post creation the master page can be changed. To accomplish this easily, the user simply needs to enable the publishing features on their my site (simply done because each my site is a personal
site collection and the use has total control). With the publishing feature activated the master page can be changed in the browser.Imagine what we could be...if we could just imagine. | Daniel A. Galant | Sr. SharePoint Solutions Architect EPC Group.net
March 19th, 2012 1:07am
True, the my site is created from the same template, and yes, post creation the master page can be changed. To accomplish this easily, the user simply needs to enable the publishing features on their my site (simply done because each my site is a personal
site collection and the use has total control). With the publishing feature activated the master page can be changed in the browser.Imagine what we could be...if we could just imagine. | Daniel A. Galant | Sr. SharePoint Solutions Architect EPC Group.net
Free Windows Admin Tool Kit Click here and download it now
March 19th, 2012 1:07am
Dear ALL,
Thanks for valulable suggestions. My question is
Can we set Master Page at that time when user click on MySite programmatically..... i.e while creation of new mysite?
March 19th, 2012 5:24am
Dear ALL,
Thanks for valulable suggestions. My question is
Can we set Master Page at that time when user click on MySite programmatically..... i.e while creation of new mysite?
Free Windows Admin Tool Kit Click here and download it now
March 19th, 2012 5:24am
Hi AishaEME,
According to your thread, you have 3 site collection in one web app. The master page of ones my site should be the same of the site collection the user belongs to.
In order to accomplish your requirement, you can use the following steps:
In order to set the master page, certain code should be executed when ones mysite is create. Unfortunately, theres no event is triggered when the mysite is created, because each mysite is actually a separate web collection, events like WebAdding will
not be triggered since an event receiver has to be registered with the site collection before it's handlers can execute.So you can use the Feature Stapling feature per this
article. Then the code of setting master page will be executed when ones mysite is create. please follow the steps given below:
Create a new sharepoint Feature called ChangeMasterPageFeature, set the scope of the feature to WebCreate the ReceiverClass of the feature called ChangeMasterPageFeatureReceiver, which is inherited from
SPFeatureReceiver, override the abstract method FeatureActivated. Write the code snippet that will set the master page by the user to the method. Actually, The code snippet setting
the master page will be discussed in depth in step 2, you can just write some code and set breakpoint on it by now.Create the Feature Stapling feature called ChangeMasterPageFeatureStapler. Set the scope of this stapling feature to WebApplication. Associate the ChangeMasterPageFeature with the template of mysite,i.e. SPSPERS
or SPSMSITEHOST, you can accomplish this by writing the <FeatureSiteTemplateAssociation> tag in elements.xml like this
<FeatureSiteTemplateAssociation
Id="<the feature
id of ChangeMasterPageFeature>" TemplateName="SPSPERS#0"/>
Activate the ChangeMasterPageFeatureStapler feature in the WebApplication. Then every newly created site using the mysite template(SPSPERS) will activate the ChangeMasterPageFeature feature and the code in method FeatureActivated will be executed.
You should write specific code which will set the master page according to the site collection the user belongs to. You can write following code to set the master page properly:
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
//SPContext.Current is null now
using (SPWeb webMySite = (SPWeb)properties.Feature.Parent)
{
//GetMasterUrlBySPUser is a function you need to write,It will
//work out the proper MasterUrl(such as "/personal/<UserName>/_catalogs/masterpage/SiteCollection1.master")
//by CurrentUser
webMySite.MasterUrl = GetMasterUrlBySPUser(webMySite.CurrentUser);
webMySite.Update();
}
}
There is a problem that
webMySite.MasterUrl seems cannot point to a MasterPage located at another site collection, e.g. "/sites/SiteCollection1/_catalogs/masterpage/default.master",You have to copy the master pages of sitecollection1, sitecollection2 and sitecollection3 to
the mysite master page gallery(i.e. directory /personal/<UserName>/_catalogs/masterpage/) programmatically,You can also accomplish this by Feature Stapling per this
artical(Writing a new <Module> tag in element.xml).
I think this approach should be work and it can accomplish your requirement.
Thanks,Lambda Zhao
TechNet Community Support
March 22nd, 2012 5:07am
Hi AishaEME,
According to your thread, you have 3 site collection in one web app. The master page of ones my site should be the same of the site collection the user belongs to.
In order to accomplish your requirement, you can use the following steps:
In order to set the master page, certain code should be executed when ones mysite is create. Unfortunately, theres no event is triggered when the mysite is created, because each mysite is actually a separate web collection, events like WebAdding will
not be triggered since an event receiver has to be registered with the site collection before it's handlers can execute.So you can use the Feature Stapling feature per this
article. Then the code of setting master page will be executed when ones mysite is create. please follow the steps given below:
Create a new sharepoint Feature called ChangeMasterPageFeature, set the scope of the feature to WebCreate the ReceiverClass of the feature called ChangeMasterPageFeatureReceiver, which is inherited from
SPFeatureReceiver, override the abstract method FeatureActivated. Write the code snippet that will set the master page by the user to the method. Actually, The code snippet setting
the master page will be discussed in depth in step 2, you can just write some code and set breakpoint on it by now.Create the Feature Stapling feature called ChangeMasterPageFeatureStapler. Set the scope of this stapling feature to WebApplication. Associate the ChangeMasterPageFeature with the template of mysite,i.e. SPSPERS
or SPSMSITEHOST, you can accomplish this by writing the <FeatureSiteTemplateAssociation> tag in elements.xml like this
<FeatureSiteTemplateAssociation
Id="<the feature
id of ChangeMasterPageFeature>" TemplateName="SPSPERS#0"/>
Activate the ChangeMasterPageFeatureStapler feature in the WebApplication. Then every newly created site using the mysite template(SPSPERS) will activate the ChangeMasterPageFeature feature and the code in method FeatureActivated will be executed.
You should write specific code which will set the master page according to the site collection the user belongs to. You can write following code to set the master page properly:
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
//SPContext.Current is null now
using (SPWeb webMySite = (SPWeb)properties.Feature.Parent)
{
//GetMasterUrlBySPUser is a function you need to write,It will
//work out the proper MasterUrl(such as "/personal/<UserName>/_catalogs/masterpage/SiteCollection1.master")
//by CurrentUser
webMySite.MasterUrl = GetMasterUrlBySPUser(webMySite.CurrentUser);
webMySite.Update();
}
}
There is a problem that
webMySite.MasterUrl seems cannot point to a MasterPage located at another site collection, e.g. "/sites/SiteCollection1/_catalogs/masterpage/default.master",You have to copy the master pages of sitecollection1, sitecollection2 and sitecollection3 to
the mysite master page gallery(i.e. directory /personal/<UserName>/_catalogs/masterpage/) programmatically,You can also accomplish this by Feature Stapling per this
artical(Writing a new <Module> tag in element.xml).
I think this approach should be work and it can accomplish your requirement.
Thanks,Lambda Zhao
TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
March 22nd, 2012 5:07am
Hi AishaEME,
According to your thread, you have 3 site collection in one web app. The master page of ones my site should be the same of the site collection the user belongs to.
In order to accomplish your requirement, you can use the following steps:
In order to set the master page, certain code should be executed when ones mysite is create. Unfortunately, theres no event is triggered when the mysite is created, because each mysite is actually a separate web collection, events like WebAdding will
not be triggered since an event receiver has to be registered with the site collection before it's handlers can execute.So you can use the Feature Stapling feature per this
article. Then the code of setting master page will be executed when ones mysite is create. please follow the steps given below:
Create a new sharepoint Feature called ChangeMasterPageFeature, set the scope of the feature to WebCreate the ReceiverClass of the feature called ChangeMasterPageFeatureReceiver, which is inherited from
SPFeatureReceiver, override the abstract method FeatureActivated. Write the code snippet that will set the master page by the user to the method. Actually, The code snippet setting
the master page will be discussed in depth in step 2, you can just write some code and set breakpoint on it by now.Create the Feature Stapling feature called ChangeMasterPageFeatureStapler. Set the scope of this stapling feature to WebApplication. Associate the ChangeMasterPageFeature with the template of mysite,i.e. SPSPERS
or SPSMSITEHOST, you can accomplish this by writing the <FeatureSiteTemplateAssociation> tag in elements.xml like this
<FeatureSiteTemplateAssociation
Id="<the feature
id of ChangeMasterPageFeature>" TemplateName="SPSPERS#0"/>
Activate the ChangeMasterPageFeatureStapler feature in the WebApplication. Then every newly created site using the mysite template(SPSPERS) will activate the ChangeMasterPageFeature feature and the code in method FeatureActivated will be executed.
You should write specific code which will set the master page according to the site collection the user belongs to. You can write following code to set the master page properly:
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
//SPContext.Current is null now
using (SPWeb webMySite = (SPWeb)properties.Feature.Parent)
{
//GetMasterUrlBySPUser is a function you need to write,It will
//work out the proper MasterUrl(such as "/personal/<UserName>/_catalogs/masterpage/SiteCollection1.master")
//by CurrentUser
webMySite.MasterUrl = GetMasterUrlBySPUser(webMySite.CurrentUser);
webMySite.Update();
}
}
There is a problem that
webMySite.MasterUrl seems cannot point to a MasterPage located at another site collection, e.g. "/sites/SiteCollection1/_catalogs/masterpage/default.master",You have to copy the master pages of sitecollection1, sitecollection2 and sitecollection3 to
the mysite master page gallery(i.e. directory /personal/<UserName>/_catalogs/masterpage/) programmatically,You can also accomplish this by Feature Stapling per this
artical(Writing a new <Module> tag in element.xml).
I think this approach should be work and it can accomplish your requirement.
Thanks,Lambda Zhao
TechNet Community Support
March 22nd, 2012 12:05pm