Forum Discussion

skylinegtr's avatar
10 years ago

Dynamic navigation menu

We have a Navigation Menu with a drop. Like this:

Menu.png

At the moment, I have to manually update it and set permission. Is there a way for me to create a dynamic version like the Community Browser? If I add a new category, I have to manually update the html code in wrapper. I would like to have the same functionality as the community browser, where it will update and set permission without me updating it manually.  

 

Any help will be greatly appreciated.

 

  • skylinegtr - Yes, but that would require you to do some coding.

     

    Get the community structure using an API call - e.g. /restapi/vc/categories/nested (depends whether you want to show category levels or the boards)

     

    By looking at the screenshot you shared, you can do something like:

     

    /restapi/vc/categories/id/developer/boards - this will list all the boards inside the developer cateogory (an example of lithium community).

     

    Your first API call will give you all the categories, and 2nd will give you the boards/ tkbs etc. You can then style it accordingly. The permissions would work fine as long as you don't use restadmin to make the API calls. I hope this helps.

    • PaoloT's avatar
      PaoloT
      Lithium Alumni (Retired)

      On top of what VarunGrazitti suggested, if your menu is used sitewide (I assume it's in the header) I would suggest to  cache it for the user. If you are only pulling public categories and nodes, you could even cache it at application level. As the community structure is bound to change infrequently, you may gain quite some performance if you accept some "delay" due to the cache itself.

       

      Here is a relevant TKB article showing how to create a menu in a macro, and then cache the macro itself.