How to create menu subitem dynamically ?

In my application I want to make a menu bar at the top of each screen,So I've created a theme and there is a menu(web block) that is fixed in the theme, The problem is that I want to create menu sub items dynamically so how can I do this ?

Something like this but this was created statically by dragging the screen in the menu tab

I want to make this theme takes parameters to create this menu sub items in runtime

How could I create these sub items dynamically based on input parameters ?


Hi Muhamed,

For simpler use cases, you can simply do an IF. Place all your submenu items and just put them inside IFs with your condition (e.g. CheckRole) for each of them. For complex ones, you can do an aggregate to query on the submenu and put the result on a List on your menu.

PS: My personal cloud recycled I wasn't able to send a screenshot.

Regards,
JC

Hi Muhamed,

See if this Forge component can be of any help.

Regards,

Nordin

Juan Carlos Elorde wrote:

Hi Muhamed,


For simpler use cases, you can simply do an IF. Place all your submenu items and just put them inside IFs with your condition (e.g. CheckRole) for each of them. For complex ones, you can do an aggregate to query on the submenu and put the result on a List on your menu.

PS: My personal cloud recycled I wasn't able to send a screenshot.

Regards,
JC

Hello Juan,

if I added the values from that aggregate to the list, Are these menu items in the list is going to appear automatically or not?

Another thing where should I pass the link which is supposed to navigate to when clicking on the menu item ?

the result that came from the aggregate ,in which list should it be added?


Hi Muhamed,


I guess I had to held back what I said earlier. Yes, having an aggregate of a MenuItem table will work, having the URL destination as a field. You will be using this value to on the ExternalURL.

It will work but on maintenance standpoint, it will not be a good approach.


Regards,

JC

Juan Carlos Elorde wrote:

Hi Muhamed,


I guess I had to held back what I said earlier. Yes, having an aggregate of a MenuItem table will work, having the URL destination as a field. You will be using this value to on the ExternalURL.

It will work but on maintenance standpoint, it will not be a good approach.


Regards,

JC


Hi Juan, 

I can't understand where to get the onclick property from because the menu items wil be initialized in runtime, when the application start I'll run the aggregate and fetch the menu items, I don't know what to do after running the aggregate,

Could you please read my previous reply and answer these questions ?

Could you provide me with an example ? If it's available.

Thank you.

All I want to do is to have a way to create dynamic menu items ,to reuse this functionality in several applications.

ex. when I want to use this functionality all I want to do is just adding in menu item static entity and the menus items should be created when running the application,how can I do that ?

Hi Muhamed,

if you want dynamic menu you can do one thing,

1. create a one menu webblock with your css.

2. create a server action set as function, on this server action you can take entity and add a loop on this and bind with html tag with your menus css like-

<ul>

 <li>Menu1</li>

<li>menu2></li>

</ul>

 

3. after that use value this in an expression with EncodeHtml() and set this property "Escape content -No".

when you run the application menus will dynamic created.


Hope this will help you.

Regards

Rahul Sahu