A query could be made to work, though I'm not sure you would be able to escape scripting completely.
Since this is really something that is global to the project I would consider a few options:
- Use a project global variable to hold entire structure of menu. This could be generated by a query, or could even be a persitant object using
system.util.getGlobals()
. There is a very long discussion here about the pros/cons and how to's of that here:
- Create a script that could loop through the results of the query, or even a dictionary or JSON string, and parse it to the correct format. That script should reside in a project script. For instance perhaps create a session property that calls a function
getAuthorizedMenuTree()
and returns the valid tree structure based on what ever criteria is needed, for that users authorization level.
The easiest way to acquire the JSON for your menu structure is to build it out and copy it from the component. Otherwise you can use the structure from the menu example and change the values in the appropriate places.
Another option rather than storing this in a DB table would be to use a tag with a Document Type. That method would avoid the potential pitfalls of persisting a top level variable.