The following example demonstrates the database-driven menu functionalities you can achieve using the Server-Side Menus API Add-in.
The environment used for the example is PHP/MySQL, however you can use the API to build server-side menus for any other environment (such as JSP, ColdFusion, ASP, ASP.NET, etc.) since AllWebMenus is platform-independent.
The menu in this example has both static and dynamic items. The items of the main menu and all the styles used are static and were created using the AllWebMenus intuitive interface. All items under the <products> item are dynamic and are generated automatically from the database table below:
(Download the SQL dump file here
This example was built in 7 easy steps as illustrated below:
1. Build the static part of the menu in AllWebMenus. Create an extra (hidden) item under the “Products” to hold the formating for the product items that will be added automatically. To make the extra item hidden, perform a “right-click -> Change Item to Hidden”:
(Download the example menu project here)
2. Make sure you have selected the correct domain and compiling properties:
3. Compile your menu:
4. Check and remember the variable name for the products group (S4):
5. Now Link your menu to your webpage file (usually a PHP or ASP file):
You can choose to do this either manually or automatically. We obviously recommend that you do this automatically to save time and avoid mistyping and omissions.
In this example the code connects to a database and reads the data from a table. If the record has a new category then this category is created and added to the main menu item (using the variable name we noted in step 4). Otherwise a new item is added to the last known category:
Note here that some of the items we create with newItem() use the style "sub_item_style" and some the style "sub_item_plus_style". These are the names automatically given to the styles we created within the AllWebMenus interface in the Style Editor.
All necessary technical information for using the Server-Side Menus API is adequately documented within the API download file.
(with instructions on how to install it)