Skip to content

Instantly share code, notes, and snippets.

@vman
Last active December 14, 2015 19:59
Show Gist options
  • Save vman/5140977 to your computer and use it in GitHub Desktop.
Save vman/5140977 to your computer and use it in GitHub Desktop.
(function($){
$(document).ready(function(){
var scriptBase = _spPageContextInfo.webAbsoluteUrl + "/_layouts/15/";
$.getScript(scriptBase + "sp.runtime.js",function(){
$.getScript(scriptBase + "sp.js",function(){
$.getScript(scriptBase + "sp.publishing.js", modifyNavigation);
});
});
});
function modifyNavigation(){
//Current Context
var context = SP.ClientContext.get_current();
//Current Web
var currentWeb = context.get_web();
//Navigation Provider Settings for Current Web.
var webNavSettings = new SP.Publishing.Navigation.WebNavigationSettings(context, currentWeb);
//Current Navigation (Quick Launch)
var navigation = webNavSettings.get_currentNavigation();
//Global Navigation (Top Navigation Bar)
//var navigation = webNavSettings.get_globalNavigation();
/*
unknown: 0,
portalProvider: 1 (Structural Navigation),
taxonomyProvider: 2 (You will need the Term Store Id and Term Set Id too),
inheritFromParentWeb: 3 */
navigation.set_source(1);
webNavSettings.update();
context.executeQueryAsync(function(){
alert("Navigation Modification Successful");
},function(sender,args){
alert(args.get_message());
});
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment