I was recently tasked with writing a handler to display the combined RSS feed of all MySite blogs on a SharePoint Intranet.
The handler takes into account the current user permissions (no rights to see the blog or post means you don't see it in the feed).
- Add the SharePoint Solution (*.wsp) to the solution store
C:\>stsadm -o addsolution -filename Vandest.SharePoint.MySiteBlogAggregator
- Deploy the solution using Central Administration > Operations > Solution management
- Open the web.config in 12/TEMPLATES/LAYOUTS/MySiteBlogAggregator and specify the MySite URL
The handler can be accessed as follows: http://mysitehosturl/_layouts/mysiteblogaggregator/rss.ashx
I use the mysitehosturl because paths to images in blog posts are stored relative and they don't appear when you use http://intranet/_layouts/mysiteblogaggregator/rss.ashx (unless you have your MySites on that url of course).
Feel free to use or modify this code.
- Microsoft Office SharePoint Server 2007 Standard or Enterprise
In SharePoint 2007 it is possible to handle events that occur on list items. These types of events come in two flavours: synchronous and asynchronous.
- Synchronous: happens 'before' the actual event, you have the HttpContext and you can show an error message in the browser and cancel the event
- Asynchronous: happens 'after' the actual event, there's no HttpContext and you cannot directly show an error message or cancel the event
By subclassing Microsoft.SharePoint.SPItemEventReceiver you can override the desired "event" methods.
- Synchronous: methods ending with '-ing' (ItemAdding, ItemUpdating, ...)
- Asynchronous: methods ending with '-ed' (ItemAdded, ItemUpdated, ...)
If you implement an override method you might want to place your code between the following lines to avoid raising other events unwantedly (and possibly causing an infinite loop).
Each override method has a parameter of type Microsoft.SharePoint.SPItemEventProperties that contains the item and event properties available for use. There's a bug in the SPItemEventProperties.AfterProperties dictionary that appears empty for synchronous events but it isn't. You can iterate over the dictionary to read and write to this collection ! This means that you can modify some of the inputted metadata before the actual item is stored in the list.
The thing to remember here is that the dictionary uses the field internal name as key, so field 'My custom field' could have an internal name such as 'My_x0020_custom_x0020_field'.
You can get the internal name of a field by using a tool like Stramit SharePoint 2007 Caml Viewer or as follows:
- Navigate in the browser to the 'Edit Page' of the List or Site Column
- The URL contains the internal field name
Here's a code snippet that works for synchronous events that outputs the contents of the property dictionary to the screen. It cancels the event so it's not very useable for other purposes but it could come in handy to actually see what is used for metadata.
public class MyTestEventReceiver : SPItemEventReceiver
public override void ItemAdding(SPItemEventProperties properties)
StringBuilder sb = new StringBuilder();
foreach (DictionaryEntry de in properties.AfterProperties)
string key = de.Key.ToString();
string value = de.Value.ToString();
sb.AppendLine(key + " -- " + value);
properties.Cancel = true;
properties.ErrorMessage = sb.ToString();
Today was the last days of TechDays 2008 and it was nice to see all those familiar faces again. The group of people you meet at such events just increases every year; I wonder how it would be like in 20 or 30 years from now...
I didn't sit through many SharePoint sessions but decided to go broader and expand my horizon with things like DSL and IIS 7.0. Sometimes I feel like I've hit the ceiling of what a SharePoint session can teach you. Hope I didn't miss out on too much SPKnowledge :-)
Cheers to all the folks I met on the event; it was a pleasure talking to you !