Archive for the ‘Uncategorized’ Category

SharePoint 2010 – Taxonomyfield setting Allow Fill-in option programmatically

Thursday, June 16th, 2011

So I just spent a good few hours working on this one. I needed to programmatically set a field on a library to be a navigational key filter field with the option allow ‘fill-in’ = true. Talk about a painful ride. I finally figured it out though.

The taxonomyfield has a method called Open on it. Setting that to true will set the property allow fill-in to true as well. Whew. Hope this helps someone one day.

Moving web part pages between sites/farms

Tuesday, June 8th, 2010

When you move a web part page from one site to another, and you do so using the explorer view and copy and paste, you lose the content, expected, but more important, and unexpected, you lose the TitleBarWebPart from the WEb Part Maintenance page. Once this is gone I have not found a way to get it back.

If you want to keep the title intact, save the library as a template and include content and move the entire library over.

Changing time of NEW icon on libraries

Thursday, June 3rd, 2010

stsadm -o setproperty -pn days-to-show-new-icon -pv 2

2 = days

Adding a custom theme through a feature

Thursday, June 3rd, 2010

This feature is a farm level feature. It is very simple to do. It is comprised of the theme, including all images and CSS, feature.xml and elements.xml and a .cs file that does the dynamic adding to SPTHEMES.xml, which is necessary for the theme to show up.


<?xml version=”1.0″ encoding=”utf-8″?>
<Feature xmlns=””
Title=”Custom Belltown”
Description=”Custom Belltown Theme”
ReceiverAssembly=”NEW_BELLTOWN_THEME, Version=,
Culture=neutral, PublicKeyToken=54d93db7bee0a736″
ReceiverClass =”NEW_BELLTOWN_THEME.FeatureCode.CustomTheme”>

<ElementManifest Location=”elements.xml”/>

elements.xml //in this case it’s actually an empty file

Add the theme to 12/template/themes/custombelltown/<ALL ASSETS>


using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
using System.Reflection;
using System.Xml.Linq;
using System.IO;
using System.Linq;

namespace NEW_BELLTOWN_THEME.FeatureCode
class CustomTheme : SPFeatureReceiver
private enum ModificationType { Add, Remove }

public override void FeatureInstalled(SPFeatureReceiverProperties properties)

// if necessary, loop through all sites and set theme

public override void FeatureUninstalling(SPFeatureReceiverProperties properties)

// if necessary, loop through all sites and reset theme

public override void FeatureActivated(SPFeatureReceiverProperties properties)
// do nothing

public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
// do nothing

private void ModifySPTheme(ModificationType type)
XDocument doc = null;
XNamespace ns = “”;

// path to the SPTHEMES.XML file
string spthemePath = Path.Combine(SPUtility.GetGenericSetupPath(@”TEMPLATE\LAYOUTS\1033″), “SPTHEMES.XML”);
string contents = string.Empty;

// read the contents of the SPTHEMES.XML file
using (StreamReader streamReader = new StreamReader(spthemePath))
contents = streamReader.ReadToEnd();

using (StringReader stringReader = new StringReader(contents.Trim()))
// create a new XDocument from the contents of the file
doc = XDocument.Load(stringReader);

// retrieve all elements with a TemplateID of ‘VISTA’.  At most, there should only be one
var element = from b in doc.Element(ns + “SPThemes”).Elements(ns + “Templates”)
where b.Element(ns + “TemplateID”).Value == “CustomBelltown”
select b;

// determine if the VISTA theme element already exists
bool exists = (element != null && element.Count() > 0);

if (type == ModificationType.Add)
if (!exists)
// create an XElement that defines our custom VISTA theme
XElement xml =
new XElement(ns + “Templates”,
new XElement(ns + “TemplateID”, “CustomBelltown”),
new XElement(ns + “DisplayName”, “Custom Belltown”),
new XElement(ns + “Description”, “A custom belltown theme”),
new XElement(ns + “Thumbnail”, “images/thbelltown.gif”),
new XElement(ns + “Preview”, “images/thbelltown.gif”));

// add the element to the file and save
doc.Element(ns + “SPThemes”).Add(xml);
if (exists)
// if the element exists, remove it and save