A new feature in SP 2010 is metadata navigation and filtering which allows users to filter the list or library content by using the metadata. A list owner can use this feature to promote fields on the list as key navigational fields, and users viewing those lists see a filtering user interface (UI) that enables them to filter the current list view to show items with the desired values in those fields. Metadata Navigation and Filtering works with list-level indices to support a seamless browsing experience—even in very large lists that contain tens of millions of items. This feature promotes the use of metadata and tagging by ensuring that, when items are well-tagged across multiple fields, they are inherently more discoverable than list view items that are not tagged.
A best article on how to configure this by UI is posted at the Microsoft site here. But being a developer our concern is how difficult this configuration if we want to do it in a feature. Well, answer is its quite easy. Below is the code which allows you to configure the metadata navigation and filtering.
public static void ConfigueSharedDocList(SPWeb web)
var documentList = web.Lists.TryGetList(SPUtility.GetLocalizedString("$Resources:core,shareddocuments_Title;", "core", web.Language));
if ((documentList != null) && (documentList.ContentTypesEnabled))
ConfigureMetadataNavigation(documentList, web.Site.RootWeb.Fields[new Guid("85BC739C-7C22-4B2D-A558-1C1DEC256269")]);
private static void ConfigureMetadataNavigation(SPList documentList, SPField field)
MetadataNavigationSettings listNavSettings = MetadataNavigationSettings.GetMetadataNavigationSettings(documentList);
var navHierarchy = new MetadataNavigationHierarchy(field);
var newKeyFilterField = documentList.Fields[new Guid("23f27201-bee3-471e-b2e7-b64fd8b7ca38")];
if (listNavSettings.FindConfiguredKeyFilter(newKeyFilterField.Id) == null)
MetadataNavigationSettings.SetMetadataNavigationSettings(documentList, listNavSettings, true);