When customising the SharePoint 2010 MySite there are a whole host of things you need to understand but the main one is that you can’t really modify the provisioned page in a very supportable way. Modifying the underlying MySite site definition is extremely unsupported! There are some articles on the internet which detail a process of adding a control to the masterpage which checks a manifest and makes changes to the default.aspx page contents on load. Subsequent loads are more ‘quick’ checks of the page state.
This isn’t really that ideal, something that executes on each page load and still leaves you little flexibility in terms of layout didn’t smell nice to me. My preferred approach was to provision a feature containing a custom aspx page and then another feature to set this as the MySite personal default page. Thus leaving the standard default.aspx still there untouched in the site. This approach leaves the OOB alone and if required you can rollback changes to the OOB version on deactivation.
As part of this custom page the ‘Recent Blog Posts’ web part was not provisioned into the page.
Our blog has several stapled features which replace the default content and make some additional tweaks to provision a client specific ‘enhanced’ blog. The user is now expected to ‘add new site’ when they want a blog. We also had to remove this from the MySite Host profile page.
So nothing unusual there, the blog created with no errors, works as it should and is still based on the OOB Blog site definition. A few hours later blog posts were not showing in the NewsFeed. Fearing something was fundamentally broken the investigation began. The following is the details about what’s going on in depths when the user clicks ‘Create Blog’
The fundamental problem was that when the user clicks this specific web part link it goes through some MySite specific logic to attach three event receivers to the Post list.
The ‘Microsoft.Office.Server.UserProfiles.BlogListEventReceiver’ needs to have the item added, updated and deleted events registered against the blog site Post list. This handler is responsible for generating the ActivityFeed change marker which drives the activity gathering event generation.
The OOB page contains the Microsoft.SharePoint.Portal.WebControls.BlogView web part. This web part checks for the existance of a property bag property of ‘urn:schemas.microsoft.com:sharepoint:portal:profile:blogwebid’ if this is not null or empty it renders the link for creating a new blog site. The generated url is something like ‘/_layouts/MySite.aspx?Blog=1’. As you can see this is pointing at the MySite aspx page but interesting has a query string value. This is the important part. Normally this page will simply check the existing user has a MySite and create one if not. With the query string value of ‘Blog=1’ it’s also instructed to generate a blog.
The logic basically checks the ‘urn:schemas.microsoft.com:sharepoint:portal:profile:blogwebid’ to see if a blog exists (will navigate to it if it did). If no value is set the the code will activate the ‘MySiteBlogs’ feature. This feature generates the site then sets the property. Once the site exists it will modify the list items adding the generic values. Final step is to associate the ‘Microsoft.Office.Server.UserProfiles.BlogListEventReceiver’ handlers.
With this knowledge in hand a quick addition to the custom blog stapling feature had them also attaching the missing handlers.
Activity events appear as normal and we can all sleep easy at night once more.