Dynamic menu

This example shows how to dynamically assemble the elements and sub-elements of a menu application retrieving the values ​​from the database.

Creating a menu

1. Create a new application “Menu”.

2. Access the “event” folder and click on “onLoad”.

3. Use the following code:

sc_appmenu_reset(mcr14);
sc_appmenu_create(mcr14);
sc_lookup(dscategories,”SELECT categoryid,CategoryName FROM categories”);
foreach({dscategories} as $arr_category){
sc_appmenu_add_item(mcr14,'item_'.$arr_category[0],, $arr_category[1],mcr14_2,catid=$arr_category[0];catname=$arr_category[1], , , );
$sSQL = "SELECT productid,productname FROM products WHERE categoryid = '".$arr_category[0]."'";
sc_lookup(dsproducts,$sSQL);
if(!empty({dsproducts})) foreach({dsproducts} as $arr_product){
sc_appmenu_add_item('mcr14','item_'.$arr_category[0].$arr_product[0],'item_'.$arr_category[0], $arr_product[1],mcr14_1,prodid=$arr_product[0], , , );
}
}

Note: mcr14_2 and mcr14_1 are applications that will be opened by the menu option.

4. Just run the application

Tutorials in the same category

Menu with tabs

In this example we will see how to configure the menu to open the applications in tabs. Crea...

Menu Breadcrumb

In this example, we will see how to configure the menu to show the applications of links explored b...

Menu using initial application

In this example we will see how to configure the menu to open with a loaded application. Cre...

Tree menu

This example shows how to create a tree menu. Creating the menu 1. Create a new tree menu...

Comment this post