프로그래밍 방식으로 상위 / 글로벌 탐색 설정을 탐지합니다
-
10-12-2019 - |
문제
게시 사이트 모음이 상위 네비게이션의 소스로서 관리되거나 구조적 탐색이 설정된 경우 프로그래밍 방식 으로이 설정을 사용하여 어떻게 작동합니까? SPWeb.Navigation.TopNavigationBar
속성은 전체적으로 반환합니다. 다른 네비게이션 노드 집합 (비공개 사이트의 상단 링크 표시 줄).
여기에 내가 말하는 설정이있는 몇 가지 UI 스크린 샷이 있습니다 :
not-publishing (상단 링크 표시 줄 설정) :
게시 (글로벌 탐색 설정) :
사이트가 SPNavigation.TopNavigationBar
, 관리되는 탐색 또는 해당 전역 탐색 / 상위 탐색 설정에 대한 구조적 탐색을 사용하는지 프로그래밍 방식으로 프로그래밍 방식으로 검색 할 수 있습니까?
해결책
Alright, so after peering into the inner workings of the code behind for those settings pages, I've found that you can detect the source of the publishing site's navigation by using the WebNavigationSettings
class and reading its GlobalNavigation.Source
property (a StandardNavigationSource
enum) like such:
if (PublishingWeb.IsPublishingWeb(web))
{
WebNavigationSettings settings = new WebNavigationSettings(web);
switch (settings.GlobalNavigation.Source)
{
case StandardNavigationSource.PortalProvider:
// Data source is Structured Navigation
break;
case StandardNavigationSource.TaxonomyProvider:
// Data source is Managed Navigation
break;
case StandardNavigationSource.InheritFromParentWeb:
// Root navigation data source is inherited
break;
case StandardNavigationSource.Unknown:
// The documentation for this value states:
// "Returns a value of unknown to indicate an advanced configuration
// that does not correspond to one of the standard configurations.
// This value cannot be manually assigned to the Source property."
break;
}
}
else
{
// Non-publishing site, root source is SPNavigation.TopNavigationBar
}
제휴하지 않습니다 sharepoint.stackexchange