Closed pchemguy closed 1 week ago
There was another issue. 'Help' AS menu_item
would be passed to parse_json causing an unhandled error. So I had to create a more elaborate check removing the first parse_json and only keeping it in the "with" block where a preliminary check is passed.
This is super useful !
Can we add an example to the documentation for these "conditional" menu items ? Otherwise people would never know the possibility even exists.
I am working on small demo that shows Login/Signup button to an unauthenticated user and Logout/User Profile after authentication is complete. But this one should probably be included with other examples. For this purpose, I will make a single page demo where you can hide/show some menus via a form.
Actually, I have been using conditional menus without the changes in the present pull request. These patches just simplify conditional menu code, but this ability was there already.
I have added a basic example. A more elaborate example will be a part of separate pull request.
Use parse_json helper to enable the use of the object form of "shell" with JSON containing menu items. Also in this pull request is an explicit filter on blank items (for example, generated via
NULL AS menu_item
or via'' AS menu_item
). The latter feature simplifier creation of dynamic menus based on certain conditions, such as whether the user is authenticated or not.Note, however,
'' AS menu_item
presently fails due to parse_json and should not be used.'{}' AS menu-item
apparently works fine.