-1
如何獲得使用jsom的SharePoint 2013術語驅動頁面友好的URL使用JSOM
currentTerm.get_localCustomProperties()['_Sys_Nav_FriendlyUrlSegment'])
//給未定義
如何獲得使用jsom的SharePoint 2013術語驅動頁面友好的URL使用JSOM
currentTerm.get_localCustomProperties()['_Sys_Nav_FriendlyUrlSegment'])
//給未定義
要檢索友好的URL您術語驅動頁面友好的URL可以利用SP.Publishing.Navigation.NavigationTerm
object其中:
指定導航行爲和屬性用於驅動 網站的導航和友好URL的
SP.Taxonomy.Term constructor (sp.taxonomy)
object。
指定的類包含getWebRelativeFriendlyUrl
method其中
返回友好的URL段作爲級聯路徑。
例
var scriptbase = _spPageContextInfo.webAbsoluteUrl+"/_layouts/15";
$.getScript(scriptbase +"/sp.runtime.js",function(){
$.getScript(scriptbase + "/sp.js", function() {
$.getScript(scriptbase + "/sp.publishing.js",function(){
$.getScript(scriptbase+"/sp.taxonomy.js",function(){
var termId = "--Term ID goes here--";
var ctx = SP.ClientContext.get_current();
var taxSession = SP.Taxonomy.TaxonomySession.getTaxonomySession(ctx);
var term = taxSession.getTerm(termId);
var navTerm = SP.Publishing.Navigation.NavigationTerm.getAsResolvedByWeb(ctx,term, ctx.get_web(), "CurrentNavigationTaxonomyProvider");
var friendlyUrl = navTerm.getWebRelativeFriendlyUrl();
ctx.executeQueryAsync(function() {
console.log(friendlyUrl.get_value());
},
function(sender,args) {
console.log(args.get_message());
});
})
})
})
});