2

I am using sitemapitem to display the navigation menu on our website. Our website requires an image against each structure group. So if

--menu1 (structure group 1) - image1
   -- page1 
   -- page2
--menu2 (structure group 2) -image2
   -- page1
   -- page2

I can add the image to the structure group as a metadata but then how can I read it on the view

2 Answers 2

2

Unfortunately, that part of DXA is not customizable/extensible yet. Meaning that you will have to modify the DXA Core/Framework to achieve what you want.

4
  • Would a better fit to be add the Structure Group metadata to the page output or have a separate way to "look up" that information delivery side (for example, add the images to the navigation xml)? Commented Dec 4, 2015 at 13:16
  • So I would have to modify the core module to be read the sg metadata and populate it to the navigation xml
    – Rache
    Commented Dec 5, 2015 at 9:09
  • To start with, you will have to extend the Navigation View Model: github.com/sdl/dxa-web-application-dotnet/blob/master/… Commented Dec 6, 2015 at 17:59
  • Then you could create your own TBB which gets the requires data from the SG and include it in the Navigation JSON. In the DXA web app framework it will be deserialized into your extended SitemapItem automatically. Finally, you can customize the Navigation Views to render the additional data. Commented Dec 6, 2015 at 18:05
1

As Rick lead to in his comments to his original post, you can indeed extend the DXA implementation along with a custom TBB that gets your required data into the Navigation JSON. I've done similar with component links in SG metadata. This is a good post to start on your TBB: http://www.tridiondeveloper.com/quick-tbb-serialize-component-as-json

There are also some handy methods/helpers provided in the base classes that I began to uncover that you may want to explore in the open source first. Admittedly in our implementation there currently exists some quirks regarding the default mappings in the dxa application vs how the data is being deserialized into our custom models (be careful for any embedded links containing internal or external fields).

I did find it odd that all of the Navigation bits (GetNavigationModel) are being built off of the GenerateSitemap.cs and SitemapItem model. If approached correctly with that in mind however, it will work just as well as pre DXA navigation implementations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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