Templates

Menu Generation Program

When creating a new template using Template Designer Wizard or modifying an existing template using Template Maintenance, you can Define a Menu to add to a section of the template.

If you want to define a simple menu with static contents, you can enter the individual menu components in the Menu Contents grid (the Define Menus window in the Template Designer Wizard or the Menus tab in Template Maintenance). However, situations may arise where other factors need to be considered when creating the menu contents. For example, the data source for the menu changes periodically or security checking needs to be applied to the menu contents. To define a menu that will address these types of situations, you can create a PxPlus program to generate the menu contents and then enter that program name in the Menu Generation Program field in the Define Menus window in the Template Designer Wizard or the Menus tab in Template Maintenance. A Menu Generation program eliminates the need to define the menu contents manually. Once the name of a Menu Generation program is entered, you can then specify other menu settings such as layout, border, background color/image, text color, etc.

(The ability to specify a Menu Generation Program was added in PxPlus 2016.)

Note:
When defining a menu within Template Designer Wizard or Template Maintenance, you must either enter a Menu Generation Program or enter menu contents in the Menu Contents grid. If a Menu Generation Program is entered, the Menu Contents grid will not be available for entry.

This page explains how you can create your Menu Generation program to generate menu contents.

To give you an example, the ide template was used to generate the interface below. You can select this template in Template Maintenance and look at the settings on the Sections tab. When Section 2 is selected, the Section Contents grid indicates that a menu with Menu Name=main has been defined with its positioning on the bottom of this section, horizontally centered. The Menus tab shows that the menu was generated by running the Menu Generation Program *ide/inomads/imp_ide.mnu. This section with its menu defined is highlighted below.

To guide you in creating your Menu Generation program, you may find it helpful to review the code in the *ide/inomads/imp_ide.mnu program using *IT - Integrated Toolkit, Ed+ or any other program editor.

When iNomads runs a template with custom menu settings defined, the menu data is read from the template's custom.ini file for processing. Each menu and sub-menu is assigned a menu number. If a Menu Generation program has been specified, the iNomads program creates a memory file and passes the file handle (menu_mem), along with the current menu number (menu_no), to the Menu Generation program. The Menu Generation program is responsible for populating the memory file, using a specific record format. If sub-menus are required, the value of menu_no may be incremented. When completed, the Menu Generation program will EXIT, allowing the iNomads program to merge the records from the memory file and continue processing.

To receive the menu_mem and menu_no values, every Menu Generation program must contain the following ENTER statement:

ENTER menu_mem,menu_no

The format for the write to the memory file is:

WRITE(menu_mem, KEY=key$)name$,text$,url$

Where:

key$

To conform to the formats of the menus defined in the custom.ini file, the key value must be in the following format:

   "[Menu"+STR(mnuNo:"00")+"_"+STR(mnuSeq:"00")+"]"

Where:

mnuNo is the menu number.
mnuSeq is the sequence number for items in the menu.

Examples:

   [Menu01_03] indicates that this is the key for the third item on Menu One.
   [Menu02_01] indicates that this is the key for the first item on Menu Two (a sub-menu of Menu One).

name$

Typically is the name of the task used to generate a new menu name for sub-menus.

text$

Text to display for the menu selection. See Menu Contents in Template Maintenance.

url$

URL value for the menu selection. Can contain a number of values. See Menu Contents in Template Maintenance.

Examples:

http://www.pvxplus.com

For displaying a Web page

menu:name

For a sub-menu

/inomads?txid=MENU_TRANS &param1=VAL1 &param2=VAL2

For running an iNomads transaction

Where:

MENU_TRANS

An iNomads transaction that must be created in iNomads Transaction Maintenance

param1, param2

Parameters that can be retrieved using the iNomads url_arg$ property

VAL1, VAL2

Values for the parameters param1 and param2

For the menu generation example above, the *ide/inomads/imp_ide_mnu program writes the url$ values as:

     /inomads?txid=_ide_menu&task=TASK_ID

Where:

_ide_menu

An iNomads transaction that is defined to run the *ide/inomads/inomads_mnu program

TASK_ID

A task from the tasks.dat file

Since TASK_ID could refer to any number of different task types (program, panel, report, etc.), a program was required that would launch each task when it was selected from the menu on the Web IDE page. The *ide/inomads/inomads_mnu program was created, and the value in the 'task' parameter was retrieved as trxName$ using the following:

     trxName$=%inomads'url_arg$("task",ERR=*NEXT)

When the Menu Generation program is completed, an EXIT statement is needed to return to the calling program.