Description | An object with a “type” value of “insertmenuitem” allows you to insert a new menu item into any menu you have previously defined. The “insertmenuitem” object is useful for creating menus based on records in a portal. This object is used by itself and does not need to appear within the “menu” or “submenu” objects. This object is an almost exact replica of the “menuitem” object, except that you must specify the “path” to the menu item you want to insert before so that CNS Menu knows where to insert the new item. If you want to insert a menu item as the last item on the menu, use “__LAST__” as the item name. You need to at least define the “name” and “before” values to have a valid “insertmenuitem” object.
Format
{
"type" : "insertmenuitem",
"name" : "menu item name",
"before" : "path to insert before",
"autocreatemenu" : true,
"db" : "mydb",
"script" : "myscript",
"value" : "47",
"enabled" : true,
"groupid" : "abc",
"modifierkeys" : "shift+ctrl",
"style" : "bold",
"mark" : "check",
"bgcolor" : "#FFFF00",
"fgcolor" : "#000"
}
Required Values
- "name"
Defines the name of the menu item. This name appears on the menu. If the name is defined as "-", a separator will be placed at this location in the menu instead of a normal menu item. If you are defining a menu separator, only the "groupid" and "modifierkeys" values will be used; all others will be ignored. The name of the chosen menu item can be retrieved using the CNSMenu_GetMenuChoice function.
- "before"
Defines the "path" to the menu item that you are inserting before. The "path" is made up of the menu name, followed by any submenu names, followed by the actual name of the menu item, all separated with the forward-slash, and looks like "menu name/submenu name/menu item name". If inserting as the last item, use "\_\_LAST\_\_" as the menu item like "menu name/submenu name/\_\_LAST\_\_".
Optional Values
- "autocreatemenu"
Defines whether or not CNS Menu should auto create the menu or any submenus specified in the "path" from the "before" value if they do not already exist. In other words, if you specify "my menu/Layouts/\_\_LAST\_\_" as the "before" value, but the "Layouts" submenu does not exist, CNS Menu will create it. Specify either true or false. The default value is false.
- "db"
Defines the database that contains the script for this menu item. If this is not defined, the default database from the parent submenu or menu will be used. If the parent submenu or menu does not have a database defined, the current database will be used. The default value is "".
- "script"
Defines the script to be called when the user selects this menu item. If this is not defined, the default script from the parent submenu or menu will be used. The default value is "".
- "value"
Defines a user-supplied value for this menu item. This value can be retrieved using the CNSMenu_GetMenuValue function and is also set as the "Script Parameter" if a script is called. The default value is "".
- "enabled"
Defines whether or not this menu item is enabled. Specify either true or false. If the menu item is disabled, it will appear greyed and the user will not be able to select it. The default value is true.
- "groupid"
Defines a user-supplied group identifier for this menu item. This is used in conjunction with the modifierkeys value to selectively show alternative menu items depending on which modifier keys are held down. See the Hidden Items Example in the CNS Menu example database for examples that use this attribute. This attribute is optional; default value is "".
- "modifierkeys"
Defines the modifier keys that are required in order to show this menu item. Specify "none" or "shift", "ctrl", "opt", "cmd", or combinations using the plus sign (eg. "shift+ctrl+cmd"). If the specified modifier keys are not held down when this menu is shown, this menu item will not be shown. If you are making a cross-platform solution, you will only want to use the "ctrl" and "shift" modifier keys because windows does not have the "opt" and "cmd" keys. The default value is "none".
- "style"
Defines the font style of this menu item. Specify "none" or "bold", "italic", "underline", or combinations using the plus sign (eg. "bold+italic"). The default value is "none".
- "mark"
Defines the mark for this menu item. Specify "none", "check", "bullet", or "diamond". The mark is displayed to the left of the menu item. The default value is "none".
- "bgcolor"
Defines the background color of the item. See the "menuitem" Object for an explanation of how to define the color. The default color is defined by the system.
- "fgcolor"
Defines the foreground/font color of the item. See the "menuitem" Object for an explanation of how to define the color. The default color is defined by the system.
|
---|