Question

We are using managed navigation for our site collection and subsites and I need to get some info about the pages I'm on using javascript.

I'm familiar with using using executeQueryAsync() in JSOM to send requests for information from the termstore and all, but that isn't what I'm looking for.

I'm used to using _spPageContextInfo to get various useful bits of information about the current page and site. I often just type this into the console to refer to things and check some details that I need to confirm.

I seem to remember that there is some object that is available on every page something like that has words like friendly or segment or something like that in it. I've tried many combinations and search the code, but I'm not finding it. Searching google points out all kinds of things about setting up the navigation and JSOM/REST examples.

Does anybody know about a javascript object/variable that is automatically loaded onto every publishing/managed navigation page and is similar to _spPageContextInfo?

Was it helpful?

Solution 2

Turns out to be _spFriendlyUrlPageContextInfo. Oddly it is undefined on several of my friendly url pages and defined on others. So I have no idea what is going on with that.

It returns the following properties

  • termId
  • termSetId
  • termStoreId
  • title (not sure which title, but I'm guessing the label for the term)

OTHER TIPS

Publishing page contains this _spPageContextInfo also, just make sure the script init complete.

 <script type="text/javascript">
        SP.SOD.executeOrDelayUntilScriptLoaded(cunstomLogic, "sp.js");
        function cunstomLogic() {
            console.log(_spPageContextInfo);
        }
    </script>

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top