In this article we will be seeing how to configure Navigation Hierarchies using Single value choice field in SharePoint 2010 using C# and powershell script. Refer this article to Configure Navigation Hierarchies using Single value Choice field in SharePoint 2010 through UI and basics of Navigation hierarchies. Here we will be seeing the same thing programmatically and using powershell scripts. Steps Involved:
namespace NavigationHierarchy { class Program { static void Main(string[] args) { using (SPSite site = new SPSite("http://serverName:1111/")) { using (SPWeb web = site.RootWeb) { SPList list=web.Lists.TryGetList("cl"); SPField field=list.Fields["Country"]; MetadataNavigationSettings listNavSettings = MetadataNavigationSettings.GetMetadataNavigationSettings(list); MetadataNavigationHierarchy mdnNavHierarchy = new MetadataNavigationHierarchy(field ; listNavSettings.AddConfiguredHierarchy(mdnNavHierarchy); MetadataNavigationSettings.SetMetadataNavigationSettings(list, listNavSettings, true); } } } } }
Go to the List => List Settings =>General Settings =>Metadata navigation settings => Configure navigation hierarchies. You could see the field "Country" is added successfully to the Hierarchy Fields.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: