• Sayantan Basu

Pass Additional Structure Group Information in Navigation.Json for DXA Project

Sometimes user wants to pass some additional information about the Structure Group (Like Short Title or Alternative Title), in that case this solution will help to achieve their functionality without any code change on CMS side. Here I have updated the DXA default Generate Sitemap Template in such a generic way that user can easily pass additional info via Navigation.Json to Web Application.


Imagine client wants to show short title for structure group in the top navigation in case of Mobile and Tab view. Let me show how easily you can achieve this –

1st Step >

Very First Thing, you have to Create a Meta Data Schema which will hold the additional info of Structure Group-

Here I have created One Sample Schema Just as an example –

and added 2 Schema fields like below(You can configure it as per your requirement) –XML NameDescriptionTypealternativeTitleAlternative Title (By default it will show the Structure Group Title, This field is helpful if you want to show different Title)TextshortTitleShort Title (Additional filed to show the short form of Structure Group. More useful for Mobile/Tab View)Text

2nd Step>

Edit the existing Navigation Configuration Schema – Added 2 schema fields in the Metadata Design of Navigation Configuration SchemaXML NameDescriptionTypemetaDataSchemaMetadata Schema used to pass additional data to Sitemap Json from Structure Group (leave blank if additional data not required in navigation)TextmetaDataFieldsUsed to specify the fields name want to pass from Metadata Schema (comma separated list of field names to get  the field value from Structure Group Metadata)Text

3rd Step>

Update existing Navigation Configuration Component – Here you can see I have added the Name of the Metadata Schema in the metaDataSchema filed. And mentioned all the schema fields in metaDataFields which I wanted to add in the navigation json.

So base is ready. Now download the template from here. Build it and upload the dll into the existing Generate Sitemap Template Building Blocks.

Create a test Structure Group and add the additional data for test. Here is a sample for that –

Note*: As of now the code was written for string type value, for other data type (like Component Link or Keyword, etc.) you need to customize that code accordingly.

On the web application side you can create a dictionary or a model called AdditionalData and easily fetch the value from Custom Sitemap Model

So here is the AdditionalData Model:

That’s it. Use it and Enjoy..

#Templating #SDLWeb85 #NavigationJson #DXA17 #GenerateSitemap

23 views0 comments