0

I have a new requirement from my client and performed some analysis. I would like to have your inputs on the same.

Farm Level Branding – Requirement Analysis

Scenario:

When a new site collection is created (using the site collection URL in BPOS D space), the new site collection will use the default branding provided by SharePoint based on the template chosen. To attach new branding to the site, we have developed a sandboxed solution and deployed branding (as our clients environment is on cloud). When a new sub site is created, admin has to select the default templates provided by SharePoint. Branding will be applied to sub sites either by inheriting the parent site or redeploying the branding solution package. This sandboxed solution deploys all the branding files to the site collection style library and master page galleries.

To apply branding there are few steps involved in configuration like deploying the solution package and activating the features.

Requirement:

Our client learned to create a new site collection and a sub site. So they want their branding applied to the site when a new site collection or sub site is created without any other additional activities.

  1. There are few site collections and sub sites already created and branding is applied to it using sandboxed solutions. These sites are already created using the SharePoint default site definitions (Team Site and Publishing Site). These sites has to be moved to the common solution package.
  2. All the existing sites and new sites that are to be created should have a common branding solution because if a change is required for branding then it has to be done at a single location and that will reflect on every site.
  3. In future, a new division of our client will come up with a new branding for that division.

Analysis:

Here is my analysis for getting this requirement up:

  1. Create a custom site definition with the custom branding: This will meet the client requirement for future sites, but this way #1 and #2 will not be met. Also, in future if a change is made to the branding then upgrading the site definition will not update the sites already created from old site definition.
  2. Create a feature staple and attach it to the existing site definitions: With this client has flexibility to create sites with any template (SharePoint default templates) but this way we might miss #3. Because in future their might be new branding solutions for different divisions. Also, I doubt on existing sites upgrading to the common solution package.
  3. Create a solution package that will be deployed to web application scope (as a farm solution) and that will have a feature scoped to Site Collection. This approach will meet many requirements but misses #3. Also #3 can be achieved with maintaining different features and activate it based on the target space. But this needs some level of configuration like activating features.

Environment: SharePoint BPOS D (SharePoint Online)

Could someone help me with your ideas of meeting this requirement?

Happy Coding!

1 Answer 1

1

To make this work you'll have to use the feature staple model, in which you create a Farm scoped feature which the Site scoped features should be dependent on. This needs to be done to meet the requirement of setting the branding when a new site collection is created.

The farm features should not contain anything, just be there as a controller, in case your client wish to disable this flow somewhere in the future.

In your Site scoped features you should of course have all branding related items; Masterpage, Pagelayouts, CSS, Images etc.

The next thing you need is a Web scoped feature which will apply the correct masterpages and css to the sub sites. That is done by creating an EventReceiver which will trigger some code on WebProvisioned. It is very important that you pick "When a site is provisioned" when you create the EventReceiver, else it won't work.

In the EventReceiver, inser this code:

SPWeb site = properties.Web;
SPWeb rootSite = site.Site.RootWeb;
site.MasterUrl = rootSite.MasterUrl;
site.CustomMasterUrl = rootSite.CustomMasterUrl;
site.CustomCSS = rootSite.CustomCSS;
site.Update();

This should make work in order to make new sites get the branding provided.
This way all the existing sites will also take effect of this so your client won't have to re-create them.

Of course regarding your issue with custom site definition, old sites will of course not be updated.

Hope this helps :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.