Many people have asked me how they could display new or changed items on a SharePoint site in a web part. This functionality isn't available, but since SharePoint is very extensible it's quite easy to create such a web part. So I've added a new web part to the Leadit.SharePoint.Essentials collection: WhatsNew.
By default items from all list on the SharePoint site are checked for new ones, but you can specify which lists you want to exclude by using the “Exclude lists” property (separate lists with the “;“ character). Most of the lists in SharePoint have a Title field, but there are a few exceptions (like Contacts and Links). So by default the What's New web part will display the value of Title field of each item, but in the “List fields” property you can specify for each list what field to display. The default value for this property is “Contacts=Last Name;Links=URL;”, this means that for the Contacts list, the Last Name property will be used, and for the Links list, the URL property. The “Items to display” property speaks for itself I think, just like the “Show date” and “Item icon URL” properties.
The code (which you can download) is pretty straight forward but my main concern was performance. If there are huge lists on the site, the performance could be pretty bad. But the SharePoint object model offers a nice solution for this; using a SPQuery object you can define your own queries that can be executed for a specific list. You can define the sort order and the number of items to fetch: perfect!
SPQuery query = new SPQuery();
query.Query = "<Query><OrderBy><FieldRef Name ='Modified' Ascending='FALSE'/></OrderBy></Query>";
query.RowLimit = (uint)this.ItemsToDisplay;
I've put this web part in the Leadit.SharePoint.Essentials library, that has three other web parts (for a more detailed description check my previous post):
To install these web parts: copy the DLL into the BIN folder (or put it in the GAC), copy the DWP files in the WPCATALOG folder and add the following line to the SafeControls section of the Web.Config:
<SafeControl Assembly="Leadit.SharePoint.Essentials, Version=188.8.131.52, Culture=neutral, PublicKeyToken=6f708acd0ffbe583" Namespace="Leadit.SharePoint.Essentials" TypeName="*" Safe="True" />
If you have any questions, remarks, requests,... please let them know! Just drop me a line, or place a comment.