Jaa


How to create a SharePoint theme and apply to OOB & custom web parts?

Let’s start from creating a custom theme for MOSS 2007 and WSS3.0. Here are the steps :-

1) Copy the “WHEAT” folder from “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\THEMES” and paste it in the same folder. Change the new folder name to “Navdeep”.

2) Rename the WHEAT.INF to NAVDEEP.INF inside the “Navdeep” folder.

3) Open the NAVDEEP.INF file in a notepad. Change the [info]’s title from “Wheat” to “Navdeep” as shown in the following table :-

[info]

title=Wheat

codepage=65001

version=3.00 format=3.00

readonly=true refcount=0

[info]

title=Navdeep

codepage=65001

version=3.00 format=3.00

readonly=true refcount=0

4) Change the “Wheat” to “Navdeep” under the [titles] as shown in the following table :-

[titles]

1031=Wheat

1036=Wheat

1040=Wheat

3082=Wheat

1043=Wheat

1046=Wheat

1053=Wheat

1044=Wheat

1030=Wheat

1035=Wheat

1041=Wheat

1042=Wheat

1028=Wheat

2052=Wheat

1029=Wheat

1045=Wheat

1032=Wheat

1038=Wheat

1055=Wheat

2070=Wheat

1025=Wheat

1037=Wheat

1054=Wheat

[titles]

1031=Navdeep

1036=Navdeep

1040=Navdeep

3082=Navdeep

1043=Navdeep

1046=Navdeep

1053=Navdeep

1044=Navdeep

1030=Navdeep

1035=Navdeep

1041=Navdeep

1042=Navdeep

1028=Navdeep

2052=Navdeep

1029=Navdeep

1045=Navdeep

1032=Navdeep

1038=Navdeep

1055= Navdeep

2070=Navdeep

1025=Navdeep

1037=Navdeep

1054=Navdeep

5) Open the “ C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033\SPTHEMES.XML “ and add the following code :-

<Templates>

<TemplateID>Navdeep</TemplateID>

<DisplayName>Navdeep</DisplayName>

<Description>Navdeep has a golden background with brown control areas.</Description>

<Thumbnail>images/Navdeep.gif</Thumbnail>

<Preview>images/Navdeep.gif</Preview>

</Templates>

6) Paste the Navdeep.gif file at the images folder i.e “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\IMAGES”

7) Do an IISRESET and Go to Site settings -> Site themes.

clip_image001

In one case, in a newly created theme and “theme.css” has been hard coded the OOB web parts. Here is the sample example :-

/* this gives every web part a white bg*/

#MSOZoneCell_WebPartWPQ1,

#MSOZoneCell_WebPartWPQ2,

#MSOZoneCell_WebPartWPQ3,

#MSOZoneCell_WebPartWPQ4,

#MSOZoneCell_WebPartWPQ5,

#MSOZoneCell_WebPartWPQ6,

#MSOZoneCell_WebPartWPQ7,

#MSOZoneCell_WebPartWPQ8,

#MSOZoneCell_WebPartWPQ9,

#MSOZoneCell_WebPartWPQ10,

#MSOZoneCell_WebPartWPQ11,

#MSOZoneCell_WebPartWPQ12,

#MSOZoneCell_WebPartWPQ13,

#MSOZoneCell_WebPartWPQ14,

#MSOZoneCell_WebPartWPQ15,

#MSOZoneCell_WebPartWPQ16,

#MSOZoneCell_WebPartWPQ17,

#MSOZoneCell_WebPartWPQ19,

#MSOZoneCell_WebPartWPQ20,

#MSOZoneCell_WebPartWPQ21,

#MSOZoneCell_WebPartWPQ22,

{

background-color:#000;

padding: 10px;

font-size: 10pt;

}

NOTE :- MSOZoneCell_WebPartWPQ1, MSOZoneCell_WebPartWPQ2 etc are client side ids for the web parts DIV.

Because of this modication, OOB web parts get the new setting but the custom web parts didn’t get the same look and feel. To workaround this, we have done the following changes :-

1) Created a new class named “Navdeep” in the theme.css file :-
.Navdeep{

background-color:#000;

padding: 10px;

font-size: 10pt;

}

2) Added the following javascript in all the custom web parts :-

 protected override void Render(HtmlTextWriter writer)
         {
             
             string elementID = "MSOZoneCell_WebPart" this.ClientID.ToString();
             writer.Write("<script language='javascript'>var obj = document.getElementById('" + elementID + "');  obj.setAttribute('className','Navdeep');</script>");
             base.Render(writer);
            
         }