SOLVED

SharePoint Site Global Navigation Mega Menu

%3CLINGO-SUB%20id%3D%22lingo-sub-15931%22%20slang%3D%22en-US%22%3ESharePoint%20Site%20Global%20Navigation%20Mega%20Menu%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-15931%22%20slang%3D%22en-US%22%3E%3CP%3ECurrently%20I'm%20trying%20to%20implement%20global%20navigation%20cross%20site%20collections%20(%20SharePoint%20Online%2F2016%20)%2C%20currently%20there%20are%20some%20planned%20approaches%2C%20just%20want%20to%20get%20some%20different%20ideas%20and%20options%2C%20with%20considering%26nbsp%3Bimplementation%2C%20performance%20and%20maintenance%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3COL%3E%3CLI%3EUsing%20global%20navigation%20list%2Flibrary%20at%20top%20level%20of%20site%20collection%2C%20and%20all%20the%20subsites%2C%20site%20collection%20retrieve%20the%20data%20from%20the%20navigation%20list%20using%20JSOM%2FREST%20API%20and%20build%20megamenu%20from%20client%20side.%3C%2FLI%3E%3CLI%3EUsing%20term%20store%20to%20store%20the%20hierarchy%2C%20and%20using%20out%20of%20box%26nbsp%3B%3CEM%3EManaged%20Navigation%3A%20Term%20Set%26nbsp%3B%3C%2FEM%3Eto%20display%20mega%20menu.%3C%2FLI%3E%3CLI%3EUsing%20term%20store%20to%20store%20the%20hierarchy%2C%20and%20using%20JSOM%20to%20retrieve%20the%20managed%20meta%20data%20%3CSPAN%3Eand%20build%20megamenu%20from%20client%20side.%3C%2FSPAN%3E%3C%2FLI%3E%3CLI%3EUsing%20SharePoint%20search%20with%20custom%20scope%20to%20a%20specific%20SharePoint%20list%2Flibrary%2C%20using%20search%20API%20to%20retrive%20the%20result%20and%26nbsp%3B%3CSPAN%3Ebuild%20megamenu%20from%20client%20side.%3C%2FSPAN%3E%3C%2FLI%3E%3C%2FOL%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-15931%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EResponsive%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-108151%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Site%20Global%20Navigation%20Mega%20Menu%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-108151%22%20slang%3D%22en-US%22%3EThanks%20Shawn.%20We%20are%20working%20on%20the%20publishing%20site%20now%2C%20hence%20going%20ahead%20with%20a%20custom%20master%20page.%20For%20team%20site%2C%20will%20explore%20the%20injection%20as%20you%20mentioned.%20Thanks%20Guys.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-108146%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Site%20Global%20Navigation%20Mega%20Menu%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-108146%22%20slang%3D%22en-US%22%3E%3CP%3EIf%20it's%20just%20for%20custom%20navigation%2C%20better%20not%20using%20custom%20master%20page.%3C%2FP%3E%3CP%3ESo%20I%20ended%20up%20with%20two%20version%20of%20implementation%3A%3C%2FP%3E%3COL%3E%3CLI%3EPublising%20Site%3A%20Using%20custom%20master%20page%2C%20javascript%26nbsp%3B%2Ccss%2C%20JSOM%26nbsp%3Baccess%20term%20stores.%3C%2FLI%3E%3CLI%3ETeam%20Site%3A%20No%20custom%20master%20page%2C%20with%20custom%20actions%2C%20%3CSPAN%3Ej%3C%2FSPAN%3E%3CSPAN%3Eavascript%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%2C%20css%2C%20%3CSPAN%3EJSOM%3C%2FSPAN%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSPAN%3Eaccess%20term%20stores.%3C%2FSPAN%3E%3C%2FLI%3E%3CLI%3E%3CP%3E%3CSPAN%3EUsing%20PnP-PowerShell%20for%20the%20deployment%20and%20provisioning.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLI%3E%3C%2FOL%3E%3CP%3E%3CSPAN%3EAs%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1019%22%20target%3D%22_blank%22%3E%40Franck%20Cornu%3C%2FA%3E%26nbsp%3Bmentioned%2C%26nbsp%3B%3CSTRONG%3ETaxonomyModule.ts%26nbsp%3B%3C%2FSTRONG%3Eis%20where%20the%20magic%20happens.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-107652%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Site%20Global%20Navigation%20Mega%20Menu%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-107652%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1019%22%20target%3D%22_blank%22%3E%40Franck%20Cornu%3C%2FA%3E.%20Taking%20a%20look%20at%20it%20now.%20%3A)%3C%2Fimg%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-107647%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Site%20Global%20Navigation%20Mega%20Menu%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-107647%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F79017%22%20target%3D%22_blank%22%3E%40Kannan%20Avadaiappan%3C%2FA%3E%2C%20you%20can%20take%20a%20look%20at%20the%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2FPnP%2Ftree%2Fmaster%2FSolutions%2FBusiness.StarterIntranet%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EPnP%20Starter%20Intranet%3C%2FA%3E.%3C%2FP%3E%3CP%3EThis%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FSharePoint%2FPnP%2Fblob%2Fmaster%2FSolutions%2FBusiness.StarterIntranet%2Fapp%2Fsrc%2Fmodules%2FTaxonomyModule.ts%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eclass%20%3C%2FA%3Ecould%20be%20very%20useful%20for%20your%20case%20(see%20the%26nbsp%3B%3CSPAN%3E%3CEM%3EgetNavigationTaxonomyNodes%3C%2FEM%3E%20nethod).%20You%20don't%20need%20to%20use%20the%20full%20solution.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EFranck.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-107645%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Site%20Global%20Navigation%20Mega%20Menu%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-107645%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Shawn%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUnderstand%20this%20is%20an%20old%20post.%20But%20I'm%20in%20a%20similar%20situation.%20Did%20you%20end%20up%20creating%20a%20custom%20master%20page%20or%20created%20the%20top%20nav%20using%20a%20JS%20injection%20method%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20very%20tempted%20to%20use%20a%20custom%20master%20page%20as%20my%20requirement%20is%20just%20for%20one%20publishing%20site%20collection.%20Appreciate%20your%20response.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%3C%2FP%3E%3CP%3EKannan%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-16222%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Site%20Global%20Navigation%20Mega%20Menu%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-16222%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20for%20the%20reply%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1019%22%20target%3D%22_blank%22%3E%40Franck%20Cornu%3C%2FA%3E%2C%20it%20looks%20good%20too.%3CBR%20%2F%3EI%26nbsp%3Bprobably%20go%20with%26nbsp%3BTerm%20Store%20as%20data%26nbsp%3B%3CSPAN%3Erepository%3C%2FSPAN%3E%2C%20JSOM%20to%20retrieve%20the%20data%2C%20local%20storage%20with%20expiry%20date%20%2B%20custom%20js%20event%20to%20reset%20local%20storage%20in%20the%20browser.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-16219%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Site%20Global%20Navigation%20Mega%20Menu%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-16219%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F5878%22%20target%3D%22_blank%22%3E%40Shawn%20Xiong%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIndeed%2C%20query%20the%20taxonomy%20service%20at%20every%20page%20load%20can%20be%20time%20consuming%20for%20sure%20(and%20not%20really%20usefull%20because%20links%20don't%20change%20every%20time).%20If%20you%20want%20an%20example%20showing%20how%20to%20build%20a%20cache%20system%20for%20the%20navigation%2C%20I've%20implemented%20one%26nbsp%3Busing%20a%20configuration%20list%20and%20the%20local%20storage%20capability%20of%20the%20browser.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMore%20info%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FOfficeDev%2FPnP%2Fblob%2Fmaster%2FSolutions%2FBusiness.O365StarterIntranet%2FApp%2Fsrc%2Fviewmodels%2Ftopnav.viewmodel.ts%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%20%3C%2FA%3Eand%20%3CA%20href%3D%22http%3A%2F%2Fthecollaborationcorner.com%2F2016%2F08%2F31%2Fpart-4-the-navigation-implementation%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFranck.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-16218%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Site%20Global%20Navigation%20Mega%20Menu%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-16218%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1019%22%20target%3D%22_blank%22%3E%40Franck%20Cornu%3C%2FA%3E%2C%3C%2FP%3E%3CP%3EThanks%20for%20the%20reply%2C%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FOfficeDev%2FPnP%2Ftree%2Fmaster%2FComponents%2FCore.TaxonomyNavigationComponents%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3ECore.TaxonomyNavigationComponents%3C%2FA%3E%26nbsp%3Bis%20closer%20to%20what%20I'm%20after%2C%26nbsp%3Band%20the%20SOD%20looks%20closer%20too%20me.%3CBR%20%2F%3E%3CBR%20%2F%3EJust%20one%20concern%2C%20by%20using%20managed%20metadata%20as%20datasource%2C%20will%20it%20incur%20any%20performance%20issue%2C%20surely%20I%20can%20implment%26nbsp%3Bjavascript%20client%20site%20caching%2C%20anything%20we%20can%20do%20to%20get%20better%20performance%20from%20server%2Fservice%20side.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ethanks%2C%3C%2FP%3E%3CP%3EShawn%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-16091%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Site%20Global%20Navigation%20Mega%20Menu%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-16091%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F5878%22%20target%3D%22_blank%22%3E%40Shawn%20Xiong%3C%2FA%3E.%20Maybe%20you%20can%20take%20a%20look%20at%20this%20sample%20on%20the%20PnP%20GitHub%20repository%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FOfficeDev%2FPnP%2Ftree%2Fmaster%2FComponents%2FCore.TaxonomyNavigationComponents%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FOfficeDev%2FPnP%2Ftree%2Fmaster%2FComponents%2FCore.TaxonomyNavigationComponents%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20corresponds%20to%20your%203rd%20option.%20Behind%20the%20scenes%2C%20this%20sample%20uses%20RequireJS%20and%20the%20JavaScript%20injection%20technique%20to%20build%20a%20top%20navigation%20bar.%20All%20navigation%20links%20are%20managed%20through%20a%20taxonomy%20term%20set%20and%20are%20retrieved%20via%20JSOM.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you%20want%2C%20you%20have%20also%20an%20other%26nbsp%3Bsolution%20using%20Webpack%20and%20the%20SharePoint%20%22Script%20On%20Demand%22%20loading%20technique%20(instead%20of%20RequireJS)%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FOfficeDev%2FPnP%2Ftree%2Fmaster%2FSolutions%2FBusiness.O365StarterIntranet%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FOfficeDev%2FPnP%2Ftree%2Fmaster%2FSolutions%2FBusiness.O365StarterIntranet%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20this%20case%20you%20will%20need%20to%20create%20a%20custom%20master%20page%20to%20load%20the%20JS%20files.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHope%20this%20help!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFranck.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-15953%22%20slang%3D%22en-US%22%3ERe%3A%20SharePoint%20Site%20Global%20Navigation%20Mega%20Menu%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-15953%22%20slang%3D%22en-US%22%3E%3CP%3Efor%20me%20option%203%20looks%20best.%20but%20be%20aware%20you%20do%20not%20change%20the%20masterpage..%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

Currently I'm trying to implement global navigation cross site collections ( SharePoint Online/2016 ), currently there are some planned approaches, just want to get some different ideas and options, with considering implementation, performance and maintenance

 

  1. Using global navigation list/library at top level of site collection, and all the subsites, site collection retrieve the data from the navigation list using JSOM/REST API and build megamenu from client side.
  2. Using term store to store the hierarchy, and using out of box Managed Navigation: Term Set to display mega menu.
  3. Using term store to store the hierarchy, and using JSOM to retrieve the managed meta data and build megamenu from client side.
  4. Using SharePoint search with custom scope to a specific SharePoint list/library, using search API to retrive the result and build megamenu from client side.
10 Replies

for me option 3 looks best. but be aware you do not change the masterpage..

best response confirmed by Shawn Xiong (Contributor)
Solution

Hi @Shawn Xiong. Maybe you can take a look at this sample on the PnP GitHub repository:

 

https://github.com/OfficeDev/PnP/tree/master/Components/Core.TaxonomyNavigationComponents

 

It corresponds to your 3rd option. Behind the scenes, this sample uses RequireJS and the JavaScript injection technique to build a top navigation bar. All navigation links are managed through a taxonomy term set and are retrieved via JSOM.

 

If you want, you have also an other solution using Webpack and the SharePoint "Script On Demand" loading technique (instead of RequireJS):

 

https://github.com/OfficeDev/PnP/tree/master/Solutions/Business.O365StarterIntranet

 

In this case you will need to create a custom master page to load the JS files.

 

Hope this help!

 

Franck.

 

 

Hi @Franck Cornu,

Thanks for the reply, Core.TaxonomyNavigationComponents is closer to what I'm after, and the SOD looks closer too me.

Just one concern, by using managed metadata as datasource, will it incur any performance issue, surely I can implment javascript client site caching, anything we can do to get better performance from server/service side.

 

thanks,

Shawn

Hi  @Shawn Xiong

 

Indeed, query the taxonomy service at every page load can be time consuming for sure (and not really usefull because links don't change every time). If you want an example showing how to build a cache system for the navigation, I've implemented one using a configuration list and the local storage capability of the browser.

 

More info here and here.

 

Franck.

Thanks for the reply @Franck Cornu, it looks good too.
I probably go with Term Store as data repository, JSOM to retrieve the data, local storage with expiry date + custom js event to reset local storage in the browser.

Hi Shawn,

 

Understand this is an old post. But I'm in a similar situation. Did you end up creating a custom master page or created the top nav using a JS injection method?

 

I'm very tempted to use a custom master page as my requirement is just for one publishing site collection. Appreciate your response. 

 

Thanks,

Kannan

Hi @Kannan Avadaiappan, you can take a look at the PnP Starter Intranet.

This class could be very useful for your case (see the getNavigationTaxonomyNodes nethod). You don't need to use the full solution.

 

Franck.

Thanks @Franck Cornu. Taking a look at it now. :)

If it's just for custom navigation, better not using custom master page.

So I ended up with two version of implementation:

  1. Publising Site: Using custom master page, javascript ,css, JSOM access term stores.
  2. Team Site: No custom master page, with custom actions, javascript , css, JSOM access term stores.
  3. Using PnP-PowerShell for the deployment and provisioning.

As @Franck Cornu mentioned, TaxonomyModule.ts is where the magic happens.

 

Thanks Shawn. We are working on the publishing site now, hence going ahead with a custom master page. For team site, will explore the injection as you mentioned. Thanks Guys.