Extensions Expand Table Menu Estimated reading: 3 minutes The Menu items of table forms or reports can be expanded with custom functions. The extensions can be added using the following Script Extensions: ext_gtab.inc ext_gtab_erg.inc ext_gtab_change.inc. To add a Menu item in LIMBAS, Create a function (with any function name) Specify details with the following transfer parameters: $gtabid: Table ID of the current table $formid: Formular-Id des aktuell verwendeten Formulars, im Falle des Standardformulars “null” $ID: Data record ID of the current data record, only for Record View &$gresult: Points to the result of the last database query Define the appearance of the new Menu item. Define the action performed: JavaScript statement(s) or function(s) that runs when selecting the new Menu item. Information can be returned to LIMBAS via hidden HTML form elements (hidden) in the HTML object “span id =”myExtForms””LIMBAS. For this purpose, the ‘pop_ * menu functions’ are used, from the file ./limbas_src/lib/context.lib . Further settings for the display, as well as the JavaScript statements/functions, are passed on to the function as parameters. Assign a new function to a table and a menu using the following command. if(!$gLmbExt[$menuToBeExtended][$gtabid]){ $gLmbExt[$menuToBeExtended][$gtabid] = $functionName; } This corresponds to $gtabid: Table ID of the table, the menu item is added $menuToBeExtended: One of the following values, which specifies the menu to be extended: “menuChangeCInfo” → Menu item is added to the [file] → [info] menu of the edit and Record Riew “menuChangeCContext” → Menu item is added to the [file] menu of the edit and Record View “menuChangeCDisplay” → Menu item is added to the [view] menu of the edit and Record View “menuChangeCExtras” → Menu item is added to the [extras] menu of the edit and Record View “menuChangeCReport” → Menu item is added to the [extras] → [reports] menu of the edit and Record View “menuChangeItems” → Menu item is added to the Main Menu of the edit and Record View “menuChangeIcons” → Menu item is added to the toolbar in the edit and Record View “menuListCInfo” → Menu item is added to the context menu of the [info] menu in the Record List “menuListCContext” → Menu item is added to the context menu in the Record List “menuListCDisplay” → Menu item is added to the [view] menu in the Record List “menuListCExtras” → Menu item is added to the [extras] menu in the Record List “menuListCReport” → Menu item is added to the [extras] [reports] menu in the Record List $functionName: Name of the function, displayed in the menu Example: function MyExt_MenuExtras($gtabid,$formid,&$gresult){ $toDoOnClick = "document.getElementById('myExtForms').innerHTML = '<input type=hidden id=myExtForms_testme name=myExtForms[test]>';\ document.getElementById('myExtForms_testme').value='".$gresult[$gtabid][2][0]."';send_form(1);\""; pop_line(); pop_menu2("menuItemText",null,null,null,"cursor:pointer", $toDoOnClick); } if(!$gLmbExt["menuListCExtras"][3]){ $gLmbExt["menuListCExtras"][3] = "MyExt_MenuExtras"; } if($myExtForms["test"]){ lmb_alert($myExtForms["test"]); } This example creates a new menu item in the menu ‘Extras’ in the Record List for the table with the ID”3″, which returns the result of the query of the field with the ID “2” to the script (LIMBAS). LIMBAS displays the result in a custom window.