Friday, September 10, 2010

Change Default Sharepoint site theme

 When you create new sharepoint site using any Template (Team site,Blank Site , Blogs etc.)  default it sets blue colored Theme (i.e Default Theme).

We can change this above default set them to any themes provided by SharePoint (Verdant,Petal etc) .
using below steps.

1. Create layout page (application page) as changeTheme.aspx .
2. In Code behind of page on page load write below code as

protected void Page_Load(object sender, EventArgs e)

{
SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPWeb web = SPControl.GetContextWeb(Context);

web.AllowUnsafeUpdates = true;

web.ApplyTheme("Verdant");

web.Update();

web.AllowUnsafeUpdates = false;

Response.Redirect(web.Url);

});

}

3. Delpoy this page to layouts Directory .

4. In ONET.XML of Team site template add <ExecuteUrl> tag Inside <Configuration> node as shown

<Configurations>

<Configuration ID="0" Name="Default">
<Lists/>

<Modules/>

<ExecuteUrl Url="_layouts/changeTheme.aspx" />

</Configuration>

<Configurations>

5. Add same <ExecuteUrl> for other templates ONET.XML and Restart IIS.
6. Create Site using Team Site Template ur Site will get created with Theme set to Verdant.
 
Thats it !! Done ...

No comments:

Post a Comment