Archive for May, 2011

SharePoint 2010: Ribbon Customization – Adding button in Editing Tool Tab


When a user click in Content Editor web part, a button appear in the “Editing Tool -> Insert” tab.


Following XML did the trick and we deploy it as feature.












          LabelText=Add Link Button

          ToolTipTitle=Add Link Button

          ToolTipDescription=Create link.

          TemplateAlias=o2 />








            Size=LargeLarge />




EnabledScript=javascript:returningtrue(); />




Leave a Comment

PowerShell Script: Change Site Theme


We have customized a site theme as explained in previous post. Now, we need to apply it on Site and all its webs.


$name = [Name of theme]

$filepath = [Path of the theme]

$bytes = [System.IO.File]::ReadAllBytes($filepath + “\” $name);

$site = Get-SPSite(“url of site collection”)

$rootWeb $site.RootWeb

$list $rootWeb.Lists[“Theme Gallery”]


$theme = [Microsoft.SharePoint.Utilities.ThmxTheme]::Open


foreach($web in $site.AllWebs)




Leave a Comment

SharePoint 2010: Customize Site Theme


We need to make changes in SharePoint site theme and apply it on site collection and all webs under that site.


We will take two simple changes like changing the color of “Text/Background – Dark 2” and “Text/Background – Light 2” of theme “Convention”.

Enclosed in red rectangle in the figure below are the two colors which needs to be change.

First step is to download the theme “Convention”. Go to “Site Settings” -> “Galleries” -> “Themes”. Save theme on your local disk.

Open it in “PowerPoint 2010” and go to “Design” tab and click on “Colors”, following window will appear:

Click on “Create New Theme Colors..” and following screen will appear:

Change the color of “Text/Background – Dark 2” and “Text/Background – Light 2” as per need and save the theme with different name.

Upload the theme in “Themes” gallery and apply it on the site. Bad news is that it will not be applied on all the webs under the site.

For this, we wrote a PowerShell script available at this url

Leave a Comment

SharePoint: Get All Possible Values of Choice Column Dynamically


We need to populate an asp DropDownList control with all possible values of a choice column created in a specific SharePoint list.


SPList spList = spWeb.Lists[“ListName”];

SPField spField = spList.Fields[“ColumnName”];

XmlDocument xmlDoc = new XmlDocument();


XmlNodeList nodeList = xmlDoc.SelectNodes(“/Field/CHOICES/CHOICE”);

foreach (XmlNode node in nodeList)




Leave a Comment

SharePoint 2010: PowerShell Script to Create SiteCollection using Custom Template


We need to write PowerShell script to create site collection using custom template.


First, we need to save site as template. For this, “Site Settings” -> “Save site as template”. Enter site template name, say, testCustomtemplate. After saving, go to “Solution Gallery” and download the testCustomtemplate.wsp.

Second, add the wsp. For this, run SharePoint PowerShell and run following commands:

Add-SPSolution [Path to testCustomtemplate.wsp]

Install-SPSolution –identity testCustomtemplate.wsp

Third, run following script making appropriate changes:

$newSite = New-SPSite -Name [SiteCollectionName] -Url [URL] -OwnerEmail [OwnerMail] -OwnerAlias [OwnerLogin] -SecondaryOwnerAlias [SecondaryOwnerLogin]

Enable-SPFeature -Identity [FeatureGuid] -Url $newSite.Url

$rootWeb = $newSite.RootWeb


You need to find values of two variables. One is “FeatureGuid” and other is “CustomTemplate”.

FeatureGuid can be found out by simply going to 14 hives, go for folder containing the name “WebTemplate” along with your solution name and copy feature ID. Like we have feature ID {e27e2916-5eb2-4a23-901b-fb3f386136bb}.

CustomTemplate can be manually created by concatenating the name of the solution and feature as under:

{e27e2916-5eb2-4a23-901b-fb3f386136bb}# testCustomtemplate

Or run following simple script after activating the feature on site collection:

$site = Get-SPSite [SiteCollectionURL]

$web = $site.RootWeb

$templates = $web.GetAvailableWebTemplates(1033) //1033 is Culture ID.

Foreach($temaplte in $templates)




Comments (2)