Tutorial: 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

The macro group in the “sc_appmenu” menu will perform the dynamic creation of the items. To learn more about these macros and other menu macros, access the full documentation .

Tutorials in the same category

Menu with Font-Awesome

For the items in a menu to have icons of the new Font-Awesome functionality and design, do the ...

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 tutorial, we will see how to configure the menu to display a navigation path with the links...

Tutorial: Menu using Initial Application

In this tutorial we will see how to configure the menu so that it is already open with an applicati...

Comment this post