0

I have been given a navigation challenge.

We have multiple site collections on a farm, that we ultimately want to have a navigation link list that is global between all site collections.

The links are defined in a global Term Store, and we want each site to use that as their navigation list, but apparently this isn't straightforward according to our one developer.

It seems a suggested solution would be to somehow query this Term Store list and populate the links on each site collection.

I came across this link -> http://www.vrdmn.com/2012/12/working-with-taxonomy-and-javascript-in.html

am I on the right track with that link? Which peice of code is the right one to use of the suggested 5? (Im new to sharepoint and VERY new to the idea of term sets. Not sure what is the right approach here to query and generate the list of links- parent and children)

Is there maybe another way?

Thanks!

1

Here is the other example that you can prefer,

SP.SOD.executeOrDelayUntilScriptLoaded(function() {
    'use strict';
    var nid = SP.UI.Notify.addNotification("<img src='/_layouts/15/images/loadingcirclests16.gif?rev=23' style='vertical-align:bottom; display:inline-block; margin-" + (document.documentElement.dir == "rtl" ? "left" : "right") + ":2px;' />&nbsp;<span style='vertical-align:top;'>Loading navigation...</span>", false);

    SP.SOD.registerSod('sp.taxonomy.js', SP.Utilities.Utility.getLayoutsPageUrl('sp.taxonomy.js'));
    SP.SOD.executeFunc('sp.taxonomy.js', false, Function.createDelegate(this, function () {
        var context = SP.ClientContext.get_current();
        var taxonomySession = SP.Taxonomy.TaxonomySession.getTaxonomySession(context);
        var termStore = taxonomySession.get_termStores().getByName(termStoreName);
        var termSet = termStore.getTermSet(termSetId);
        var terms = termSet.getAllTerms();
        context.load(terms);
        context.executeQueryAsync(Function.createDelegate(this, function(sender, args) {
            var termsEnumerator = terms.getEnumerator();
            var menuItems = new Array();

            while (termsEnumerator.moveNext()) {
                var currentTerm = termsEnumerator.get_current();
                // Your code here to bind menu item.
            }
            SP.UI.Notify.removeNotification(nid);
        }), Function.createDelegate(this, function(sender, args) {
            alert('The following error has occured while loading global navigation: ' + args.get_message());
        }));
    }));
}, 'core.js');

Read this article for more: Building global navigation in SharePoint 2013

As an other approach you can prefer this article: Real Cross Site Collection Navigation In SharePoint Using The Term Store, which is creating a user control and loading data with the help of C#.

  • Thanks Pradip! I followed the first link pretty closely and am successfully querying my term set. :) The only hurdle now is that I don't know how to effectively differentiate between 'parents' and 'children'. Currently I have 5 Terms, which each have 2 terms under each. When I run the above code it lists out all 15 terms individually, losing the hierarchy. Are you familiar with how to identify which terms have children, or which terms is a parent of other terms? Can't quite figure that step out... – Simon May 12 '15 at 5:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.