Recently I was asked to create custom MySites, so I start looking how the MySites get currently created in MOSS 2007.
By using SharePoint Designer 2007 I have easily found that the Mysite link is on the Master page as expected sitting inside of a <SharePoint:DelegateControl> with ControlID=”GlobalSiteLink1″.
This is great news: we can change the control by using features without directly changing the master page. If you want to read more about this special SharePoint control follow the link to “The SharePoint DelegateControl Uncovered” on Patrik’s Blog.
For now let’s continue explaining the current implementation done by Microsoft.
The current control is “~/_controltemplates/mysitelink.ascx” with a sequence of 100 and points on the My Site Web App to a system page named “/_layouts/MySite.aspx”.
The “~/_controltemplates/mysitelink.ascx” control inherits the Microsoft.SharePoint.Portal.WebControls.MySiteLinkUserControl class inside the Microsoft.SharePoint.Portal.dll assembly.
The next step was to take the Reflector and look inside that class.
The “/_layouts/MySite.aspx” page is hard coded (bad bad practice) inside the SetControl() method.
The MySite.aspx system page inherits the Microsoft.SharePoint.Portal.WebControls.CreatePersonalPage class inside the Microsoft.SharePoint.Portal.dll assembly.
On the FormLoad() method there is code to look for the userProfile.PersonalSite that is the equivalent of userProfile[PropertyConstants.PersonalSpace] and if empty create a new site by calling userProfile.CreatePersonalSite() public method.
Moving forward I found that inside that method the site template is hard coded (bad bad practice) to SPSPERS#0.
Now armed with all this information we can decide how to create a custom one.
There are few approaches:
1) Just modify the SPSPERS#0 site template on the file system.
2) Modify the MySite.aspx to derive from another page that you created and on FormLoad() create the site from another template. Make sure that you create the site during the POST because it does not work if trying to create it during GET.
3) Create a new MySiteLink control with a sequence lower than 100 that will replace the default one for MySite and point to a different system page of your own. That page will create the personal site or redirect to one if another already exists.
The preferred approach would be 3) as it offers the maximum flexibility and has the minimal impact on the farm if Microsoft decides later on to change the mechanism. Plus this option offers the possibility to safely deploy the custom MySites as a solution that later on will not be affected by HotFixes or Service Packs.