Recursive List Records Web block

Recursive List Records Web block

We are looking into creating a drop down menu build with UL/LI.  The menu needs to have multiple levels of sub-menus.

We have built a working menu with only one level of sub-menu by creating a web block and including it inside of a list records widget.  The web block itself contains a list records widget. 

Is there any way to create a recursive web block to process the sub-menus or will I need to create one block for each level?
Hi Tom,

Usually you can get away without using recursion.

If for each menu entry you have a level defined and you define a code allows you to order the sumenus it should be enough.
An example would be:

level; code; MenuName
1; 1000; Menu1
2; 1100; Submenu11
2; 1200; Submenu 12
1; 2000; Menu2
2; 2100; Submeno21
3; 2110; SubSubmenu211
3; 2120; SubSubmenu212
1; 3000; Menu3
2; 3100; Submenu 31

Each record allows you to identify the depth of the menu and you can order the entries by the code.
Like this the webblock can then identify how to display each menu entry.

To have variable depths (unknown at start) you can use a decimal as the code (e.g. 2.13) and at the weblock use some indentation variable by depth.

I hope this helps.

best regards,
Thanks Vasco,

The problem comes in at the point of "use some indentation variable by depth".

I'm not sure what you mean by some variable.

We are trying to keep everything in the UL/LI structure.  The List Records widgets are the only non-expression way of getting UL/LI that I know of.  Is there another way that doesn't invlove HTML in expressions but will allow us to still use UL/LI?

Can you show me the effect you are trying to achive?
Maybe attach a simple version of your oml with the menus.

Thanks Vasco,

Here is an oml.  There are two parts, the first is a non-escaped expression which builds the UL list.  The second is a series of web blocks that so what we need to do except the web block recursion limitation requires us to have one web block for each level.

Is there a way to get around the recursion limitation?


Hi Tom,

Here is a small example of what i meant.

Is this what you need?

Notice the parts where you access the previous reccord or the following of the list:

MyListRecords.List.CurrentRowNumber = 0 or (MyListRecords.List.Current.MENU.Level > MyListRecords.List[MyListRecords.List.CurrentRowNumber-1].MENU.Level)

Thanks Vasco,

I understand what you were saying now.

This will probably work well. 

Having the ability to recursivily set it up would still be nice as we wouldn't have to worry about keeping the whole list in a specific order.

Perhaps we could use an action to build a new list and then supply that to your method.

Thanks Again,