Difference between revisions of "MenuLiteral Element (Data)"

From HLKitWiki
Jump to: navigation, search
(The "menu_literal" Element)
Line 17: Line 17:
 
|}
 
|}
  
The "menu_literal" element also possesses child elements that define additional additional facets of the portal. The list of these child elements is below and must appear in the order shown. Click on the link to access the details for each element.  
+
The "menu_literal" element also possesses child elements that define additional facets of the portal. The list of these child elements is below and must appear in the order shown. Click on the link to access the details for each element.  
  
 
:{| class="infotable"
 
:{| class="infotable"

Revision as of 00:21, 2 December 2008

Context: HL KitKit Reference … Data File Reference … Portal Element (Data) 

The "menu_literal" Element

Menus are useful whenever you need the user to select exactly one item from a collection of options. The role of the "menu_literal" element is to allow you to specify a fixed set of options to choose from. An classic example is the selection of gender on the "Personal" tab, where a menu allows the user to select either male or female. The complete list of attributes for this element is below.

field Id – Specifies the unique id of the field whose contents reflect the current selection from the menu. The field must be a text-based field and must exist within the pick/thing associated with the containing template. If this portal is not defined within a template, a menu is not allowed.
maxvisible (Optional) Integer – Specifies the maximum number of items that will be visible at one time within the menu when the user opens it for selection. If there are more items to choose from, a scroller will allow the user to access them. Default: "5".
allowuservalue (Optional) Boolean – Indicates whether the user is allowed to type in a custom value for use within the menu. If the user does this, the value saved for the menu is simply the text entered by the user. Default: "no".

The "menu_literal" element also possesses child elements that define additional facets of the portal. The list of these child elements is below and must appear in the order shown. Click on the link to access the details for each element.

choice One or more "choice" elements must appear as defined by the given link. This element defines the individual options that the user can select from.
change An optional "change" element may appear as defined by the given link. This element defines a Change Script for the portal.

The "choice" Element

The "choice" element defines an option that is listed within the menu for the user to select. Each choice has two facets: the value shown to the user and the value used internally. The complete list of attributes for this element is below.

display Text – Specifies the text to be displayed for this choice.
value (Optional) Text – Specifies the text to be tracked internally for this choice. When the user selects the choice, the value is saved into the associated field. If empty, the "display" text is used as the value. If the field used by the menu is value-based, all "value" attributes must be numeric values. Default: Empty.

The "change" Element

The "change" element defines a Change Script for the portal that is invoked whenever the user selects a new choice from the list of options. This script allows the implications of the new selection to be integrated and the display updated. The complete list of attributes for this element is below.

PCDATA Script – Specifies the code comprising the Change script.

Example

The following example demonstrates what a literal menu portal might look like. All default values are assumed for optional attributes.

<portal id="gender" style="menuNormal">
  <menu_literal field="perGender">
    <choice value="0" display="Gender: Male"/>
    <choice value="1" display="Gender: Female"/>
    </menu_literal>
  </portal>