2015-05-12 30 views
1

在發佈SharePoint 2013站點時,我使用的是託管導航。我需要讀取term store中定義的自定義屬性的值,並且還需要讀取description字段的值。是否有可能通過閱讀網站進行訪問?如何閱讀Sharepoint 2013中NavigationTerm的自定義屬性值和術語描述?

我可以獲得TaxonomyNavigationContext.Current.NavigationTerm並閱讀基本信息。但要閱讀自定義屬性和描述,我需要獲取分類術語,並且不能使用只讀緩存導航術語。

TaxonomySession session = new TaxonomySession(site); 
NavigationTerm navTerm = TaxonomyNavigationContext.Current.NavigationTerm; 
Term term = navTerm.GetTaxonomyTerm(session); // I cannot do it due to permission level - user is read only user! 
string val = term.CustomProperties["..."]; // this is what I need - read value of custom property - but without need to access Term class. 

有沒有辦法如何從只讀導航條款讀取自定義屬性與用戶分配讀權限?

回答

0

這項工作對我來說SEO的屬性,如果你調試你能看到的屬性,你可以得到CustomPropertiesLocalCustomProperties集合。

SPSite site = new SPSite(siteGuid); 
SPWeb web = site.OpenWeb(); 

TaxonomySession session = new TaxonomySession(site); 
NavigationTerm navTermino = TaxonomyNavigationContext.Current.NavigationTerm; 
Term termino = navTermino.GetTaxonomyTerm(session); 

//var seoTitle = termino.CustomProperties.Where(o => o.Key == "_Sys_Seo_PropBrowserTitle").SingleOrDefault(); 
var SEOPropBrowserTitle = termino.LocalCustomProperties.Where(o => o.Key == "_Sys_Seo_PropBrowserTitle").SingleOrDefault(); 
var SEOPropDescription = termino.LocalCustomProperties.Where(o => o.Key == "_Sys_Seo_PropDescription").SingleOrDefault(); 
var SEOPropKeyWords = termino.LocalCustomProperties.Where(o => o.Key == "_Sys_Seo_PropKeywords").SingleOrDefault(); 
var SEOPropSiteNoIndex = termino.LocalCustomProperties.Where(o => o.Key == "_Sys_Seo_PropSiteNoIndex").SingleOrDefault(); 
相關問題