i:0#.w|Ali.Mazaheri

Azure, Open Source, SharePoint and ...

Developing a custom MySite host site definition using VSeWSS 1.3

In MOSS 2007 as part of the SSP provisioning process “SPSMSITEHOST” site definition is being used to provision the MySite host (Root site) which provides access to user profile information through “person.aspx” and “SPSMSITE” site definition used to provision a personal site collection for each individual user.

One thing to consider is while each user owns a seperate site collection as personal site, MySite host is shared among all users and changes to “Person.aspx” will affect all users. Feature Stapling is my method of choice for customizing or extending the OOB “SPSMSITE” features as explained in this great post by Steve Peschka. As for customizing the MySite host, in most cases changes should be applied directly to “Person.aspx” file or the related "ONET.XML”. As best practice it is always recommended not to modify the OOB site definitions and although SharePoint Designer can be used to apply changes to “Person.aspx”(which leaves the page as un-ghosted) in scenarios where changes should be deployed from one environment to another (e.g. from Development to QA and eventually Staging and Production) leveraging a custom site definition wrapped in a solution package is a better approach.

Following explains the steps to create and deploy a custom MySite host site definition based on the OOB “SPSMSITEHOST” site definition using Visual Studio 2008 extensions for Windows SharePoint Services v 1.3 and STSADM command:

  1. Create a new project using “Blank Site Definition” template 
    image
  2. In VS 2008 copy over “ONET.XML”, “Person.aspx”, “Default.aspx”, “Discussion.aspx” and “Blog.xsl” files from “12\Templates\SiteTemplates\SPSMSITEHOST” folder under “CustomMSITEHost"\Site Definition”
    ScreenHunter_03 Feb. 18 14.58
     
  3. Make sure to add the required namespaces to the <Project> element in the new “ONET.XML” file and change other sections if required

    ONET.XML

    <?xml version="1.0"?>

    <Project  Revision="2" xmlns:ows="Microsoft SharePoint" xmlns="http://schemas.microsoft.com/sharepoint/" SiteLogoUrl="/_layouts/images/mysite_titlegraphic.gif">

    </Project>

  4. Change the “ID” value from 1 to 0 in “WebtempCustomMSITEHOST.XML” so it references the default configuration in “ONET.XML”

    webtempCustomMSITEHOST.XML

    <?xml version="1.0" encoding="utf-8"?>

    <Templates>

      <Template Name="CustomMSITEHOST" ID="10001">

        <Configuration ID="0" Title="CustomMSITEHOST" Description="" Hidden="FALSE" ImageUrl="/_layouts/images/stsprev.png" DisplayCategory="Development" />

      </Template>

    </Templates>

  5. Modify the “Person.aspx” file (In this example a border attribute is added to the html table for “Business Card” section)

    Person.aspx

    <!– business card –>

    <table cellspacing=0 cellpadding=0 width="100%" style=’table-layout:fixed;word-wrap:break-word;’ border=”1”>

    <tr>

    <td class="ms-vb ms-announcementtitle ms-profilevaluelarge" id="ProfileViewer_ValueTitleDept">

     <SPSWC:ProfilePropertyValue PropertyName="Title" class="ms-profilevalue" runat="server" /><SPSWC:ProfilePropertyCheckValue PropertyNames="Title,Department" runat="server" Text=", "/><SPSWC:ProfilePropertyValue PropertyName="Department" class="ms-profilevalue" runat="server" />

    </td>

    </tr>

    <tr>

    <td class="ms-vb ms-announcementtitle" id="ProfileViewer_ValueOfficePhone">

    <span class="ms-profilevaluesmall"><SPSWC:ProfilePropertyValue PropertyName="Office" class="ms-profilevalue" runat="server" /><SPSWC:ProfilePropertyCheckValue PropertyNames="Office,WorkPhone" runat="server" Text=" &nbsp; "/><SPSWC:ProfilePropertyValue PropertyName="WorkPhone" dir="ltr" class="ms-profilevalue" runat="server" /></span>

    </td>

    </tr>

    <tr>

    <td valign=top class="ms-descriptiontext" id="ProfileViewer_ValueAboutMe">

  6. Switch to WSP view and make sure that all the elements and files included in solution package
    ScreenHunter_07 Feb. 20 14.19
  7. From “Solution Explorer” tab, build and deploy the package
       ScreenHunter_11 Feb. 20 21.39
  8. Confirm that the solution package has been deployed successfully, at this point "My Profile" information should be displayed via OOB “Person.aspx”
    ScreenHunter_10 Feb. 20 21.37
  9. Delete the root MySite host site collection and provision a new site collection based on the custom template (i.e. CustomMSITEHost)
    ScreenHunter_12 Feb. 20 21.50
  10. Refresh the profile page and notice the change
    ScreenHunter_13 Feb. 20 21.51