SharePoint Blogs / SharePoint University
SharePoint Blogs and SharePoint University - all in one place!
Need SharePoint Training? Attend a SharePoint Bootcamp!

Please delete cookies related to sharepointblogs.com and sharepointu.com to resolve login issues!

Customizing the My Site look and feel

As a reaction to my post about adjusting the top level navigation on My Sites I got an email asking how you go about adjusting the look and feel of a My Site. Since I also touch upon that topic in a lot of my presentations I decided to write it down.

The problem with putting a design on My Sites is that you can't change the master page and the style sheet of your My Site through the user interface. This problem also occurs when you migrate a SharePoint 2003 environment with (a lot of) My Sites to SharePoint 2007. All these My Sites need to get the correct visual design and since all My Sites are site collections they can't inherit their master page and style sheets either.

I wanted to create a solution to this problem for both existing sites and new sites. I will use this blog post to describe the solution.


The basics

For both the deployment of a design on existing My Sites and the activation of a design on new My Sites a feature with the master page is needed. Also a style sheet needs to be deployed. The design feature looks like this:

The feature.xml file stores the metadata of the feature.

The scope of the feature is "Web"(=sub site) where you might expect "Site"(= site collection), the reason I chose web was that if you have a site with a lot of sub sites and you want to save one of the sub sites as a template and the sub site inherits it's master page from the site collection it resides under it occasionally won't save the correct design in the template.

There are two files that need to be deployed with this feature, the master page file and the element manifest file of the feature, design.xml. There is also a feature receiver for this feature that, on activation and deactivation will set the correct master page, style sheet and title graphic.

The element manifest file design.xml describes the inner workings of the feature. In this case the main purpose of the feature is to deploy the custom master page to the master page gallery.

The style sheet is deployed from a separate project that is used to deploy custom files to the MOSS 2007 12 directory (C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\). The structure of this project is the same as the structure of the 12 directory.

The featurereceiver will take care of assigning the correct master page and style sheet to each sub site the feature is activated on. If the feature is deactivated the default master page will be assigned again and no custom style sheet will be applied.

 


New sites

In order to activate the feature on all My Sites that are created from the moment you activate your feature on you can build a stapling feature. Feature stapling is a very cool thing in MOSS 2007 where you can build a separate feature to tie site definitions and features together.  Using feature stapling you can create an blank site (not based on the MOSS 2007 blank site!) and staple all functionality you want to that site definition. The features that are stapled to a site definition are activated when the site is created. Feature stapling can create n-to-n relations. One feature can be stapled to several site definitions and several features can be stapled to one site definition.

The stapling feature also has a feature.xml for it's metadata. The most prominent setting in the feature.xml is the fact that the feature is activated at the "Farm" scope. This means that it will work on all web applications within the farm. This is fine, since in most environments only one web application is used for My Sites and the feature is only stapled to the My Sites site definition as you can see in the element manifest file of the stapling feature, DesignStapling.xml. This ensures that on every site that is created with the My Site site definition the design feature is activated.

 

If you didn't want to create this functionality just for My Sites, but you would build it for all sites you could staple to the GLOBAL site definition. All other site definitions inherit from the GLOBAL site definition, so stapling the design feature to this will staple the design feature to almost all site types. A prominent exception on this is the blank site. In the site definition of the blank site it is defined that you can not staple anything to the blank site (AllowGlobalFeatureAssociations="False"). This is necessary, because SharePoint itself also staples features to the GLOBAL site definition and otherwise the blank site would not be blank.


Existing sites

Feature stapling will only have an effect on sites that are created after you stapled the feature to the site definition. This means that if you already have a lot of My Sites that you want the custom design activated on you need to think of something else.
For this purpose I created a simple console application that loops through all sub sites within a web application and that activates the feature on all of them. This feature can also be used to deploy changes in the master page to already existing sites.

The application application can both activate and deactivate the design on a specific web application. In order to start it you use on of the following options:

  • -o activatedesign -url [webapp url]
  • -o deactivatedesign -url [webapp url]

Depending on whether you entered the activating or deactivating operation the application will go to the activating or deactivating function. The code for both of them is displayed below.

 


Posted 02-22-2008 9:16 PM by Mirjam

Comments

Ralf wrote re: Customizing the My Site look and feel
on 02-23-2008 8:41 AM

Na 3 weken dan toch eindelijk gelukt. Een beetje overwerken kan toch wel eens helpen dus :-) Zou ook leuk zijn als ik er iets van snapte verder.

Links (2/24/2008) « Steve Pietrek’s SharePoint Stuff wrote Links (2/24/2008) « Steve Pietrek’s SharePoint Stuff
on 02-24-2008 7:05 PM

Pingback from  Links (2/24/2008) « Steve Pietrek’s SharePoint Stuff

Mirrored Blogs wrote SharePoint Kaffeetasse 46
on 02-26-2008 2:11 AM

Web Content Management Variations Make the World Go Round WCM Site in Arabisch Zain und Sure SharePointConference

Bookmarking the web - w10/2008 wrote Bookmarking the web - w10/2008
on 03-09-2008 11:09 AM

Pingback from  Bookmarking the web - w10/2008

sharepoint mysite wrote sharepoint mysite
on 07-11-2008 6:31 PM

Pingback from  sharepoint mysite

Ajay wrote re: Customizing the My Site look and feel
on 07-14-2008 6:41 AM

Hi,

If i change my mysite's site definition will my data get lost??

Thanks,

Ajay

Flo wrote re: Customizing the My Site look and feel
on 07-14-2008 10:36 AM

Hello Mirjam

I followed your instructions to deploy a new design to our application's mysites. Everything went fine except the deployment of the css file. Could you give a brief description how it's done?

Best regards,

Flo

Mirjam wrote re: Customizing the My Site look and feel
on 07-18-2008 8:43 AM

Hi Ajay,

For starters: it's always better to add a custom site definition then adjusting the default one.

But to answer your question...

A site definition is build up out of at least three files:

* An onet.xml file that is deployed in the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\SiteTemplates\<name of the site definition>\xml folder. Changes to the onet.xml will not effect existing sites. This can be handy sometimes, but it can also be a pain in the ass if you want to make adjustments to all your existing sites.

* A default.aspx file that is deployed in the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\SiteTemplates\<name of the site definition> folder. This file contains the web part zones and adjustments will also effect existing sites. This will however not effect data, only the visibility of web parts placed in web part zones that you change or delete can be effected.

*  A webtemp.xml file in the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\<LCID>\XML folder. This is merely the registration of your site definition and some metadata, like the visibility of the site definition to the end user. Changes to this file will also not effect existing sites and will not effect any data.

So the answer is "No, you will not lose data if you change a site definition" ;:-).

Regards,

Mirjam

Mirjam wrote re: Customizing the My Site look and feel
on 07-18-2008 8:59 AM

Hi Flo,

Your stylesheet can be deployed in two locations.

* The stylelibrary

* The file system in the C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\<LCID>\STYLES folder

We deploy our stylesheets to the styles folder on the file system. Deployment to this folder will be automatic. You could build a feature for this and in the feature receiver write some code that will copy the stylesheet from the feature folder to the styles folder.

If you want to deploy your stylesheet to the stylelibrary you can add your stylesheet to the design feature.

The contents of your design.xml elements file would then be extended with:

   <Module Name=”Stylesheets” Url=”Style Library”>      

       <File Url=”Custom.css” Type=”GhostableInLibrary” />  

      </Module>

</Elements>

The <ElementManifests> tag of the feature.xml should also be extended with:

<ElementFile Location="StyleSheets\custom.css">

This means that the stylesheet with the name custom.css is stored in the StyleSheets folder in the feature folder.

I hope this helps...

Regards,

Mirjam

The Mit's Blog wrote [Best Practices] Customisation du My Site : Comment le modifier en amont et en aval
on 09-05-2008 3:48 AM

Sous entendu comment modifier les My Site de MOSS 2007 avant création et leur maintenance après création.

Dan wrote re: Customizing the My Site look and feel
on 09-11-2008 4:10 AM

Hi Mirjam,

I find your post very helpful. I am trying to customise MySite to be identical to a masterpage which I designed in Sharepoint Designer using a css file.

However, you mention a 'Design' folder, at the start of your topic, and I would like to know at what location within the sharepoint directory i.e C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\, would this 'Design' folder be stored?

I would really appreciate if you could specify the exact location, for the 'Design' folder, within the actual directory?

Should I manually create this 'Design' folder and then add the various files to it?

I look forward to hearing from you.

Regards,

Dan

Dan wrote re: Customizing the My Site look and feel
on 09-11-2008 4:43 AM

Hi Mirjam,

Do you happen to have zip files of the sample-code which you use in your document, to describe the process? On my web-browser, part of the code, is omitted from the screen and I can't view it all. (The end of each line, is omitted).

Regards,

Dan

Hammad wrote re: Customizing the My Site look and feel
on 09-12-2008 11:16 AM

Hi i have a question i customize mysite for all users but when a new user came then MyHome page is not skinned user need to activate the feature for himself, can you tell how can i deploy a feature gloabally so that no user need to activate the mysite feature

Dan wrote re: Customizing the My Site look and feel
on 09-23-2008 3:47 AM

Hi there, Is there anywhere on the web that gives a full detailed account on how to customise 'MySite'.

I have tried various approaches, which I found on the web, and they all failed.

I am using MOSS 2007 and I can't find adequate support, anywhere, for the customising of MySite.

It is my opinion that this issue needs to be addressed urgently, by Microsoft. I think that some solution needs to be found and incorporated into the next release of Sharepoint.

Dan

Pankaj wrote re: Customizing the My Site look and feel
on 12-18-2008 12:07 AM

Hi

can u plz tell location of  

Design

             Feature

                            Masterpage

in the site for Changing the look and feel of MY Site

Hannah wrote re: Customizing the My Site look and feel
on 01-07-2009 9:04 AM

Hi

Can you provide a working example of the solution code for download please?

Many thanks

Hannah

Saurabh Kumar Singh wrote re: Customizing the My Site look and feel
on 04-30-2009 1:46 PM

Hi,

I am creating a Community Site in MOSS 2007 with customization and also want to use existing My Site(basically “My Pofile”) feature for each user’s profile like ORKUT fashion(which maintains GROUPS, FRIEND’s List, SCRAPBOOK, MESSAGES etc.). Can i use “My Site” feature of this purpose??

Can you please help me in this context??

Thank you,

Saurabh

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Need SharePoint Training? Attend a SharePoint Bootcamp!
Posts (c) their respective authors. Everything else (c) 2009 SharePoint Experts, Inc.