maandag 16 maart 2009

SharePoint Best Practices Seminar

On April 3rd 2009 a SharePoint best practices seminar will be held at Microsoft headquarters in the Netherlands.

Some of the speakers will be: Joel Olesson, Mike Watson, Daniel McPherson and Waldek Mastykarz.

I expect loads of interesting SharePoint subjects, so I will definitely be there! You can register here. (but hurry because there's a limited capacity).

Remove Folder from style library

I recently had to modify a feature which had provisioned some stylesheets and images to the style library. One of the things I had to do was remove all the provisioned files and folders when the feature was deactivated.

Amongst others a folder within IMAGES had to be removed in an feature-receiver during FeatureDeactivating. To do this I followed the next steps:

1.
First I got a reference to the Style Library:
SPWeb rootWeb = ((SPSite)properties.Feature.Parent).RootWeb;
SPList styleLibrary = rootWeb.Lists["Style Library"];


2.
Next I had to get a reference tot the IMAGES folder. There probably are more ways to do this, but what I did was loop through the folders until I found the IMAGES folder:
foreach (SPFolder folder in styleLibrary.RootFolder.SubFolders)
{

  if (folder.Name.Equals("Images", StringComparison.OrdinalIgnoreCase))
  {
  }
}

3.
Now, last-but-not-least, in the above if statement you should find the folder you're looking for and delete it:
for(int i = 0; i < folder.SubFolders.Count; i++)
{
  if(folder.SubFolders[i].Name.Equals("MyFolder", StringComparison.OrdinalIgnoreCase))
  {
    folder.SubFolders[i].Delete();
  }
}

woensdag 4 maart 2009

stsadm upgradesolution and new features

I've had a few people come up to me and ask me why they can't find their new features after they did an stsadm -o upgradesolution.

To make things clear, the scenario is as following: example.wsp is deployed and contains two features, feature-A and feature-B.

If, for example, you add a new feature (feature-C) to example.wsp, and deploy it using stsadm -o upgradesolution, then you will not find the new feature in your feature overview. Neither in the site features nor the site collection features will you find feature-C.

It looks like feature-C wasn't deployed. But wait.... the feature can be found in the 12-hyve. See what happened? The feature is deployed but not installed!

So if you do a simple stsadm -o installfeature and presto: the feature will appear in the features overview.