optList

Generates an option list.

This function is used extensively to create option lists on Content Server pages.

This function only produces output when used with a service that calls loadMetaOptionsList

Type and Usage

Parameters

Takes one parameter and one optional argument to the parameter:

The only parameter is a field name, option list key, or a variable.

  • Field name syntax is <$optList fieldName$>. For custom metadata fields, the field name will resolve to <$optList xFieldName.options$>, or you can specify the .options suffix directly.

  • Option list key syntax is <$optList ListName$>.

    • For standard metadata fields, the ListName is the name of the internal option list (such as docAuthors). See Internal Option Lists.

    • For custom metadata fields, the ListName is the name of the option list key, such as FieldNameList.

  • Variable syntax is <$optList variable$>. The variable must resolve to a field name or an option list key.

  • One of the following optional arguments can be added to the parameter:

    • :noselected-No values are selected when the option list is displayed.

    • :fieldValue-The value specified by the fieldValue variable is selected as the default value in the option list.

Output

Returns a list of values.

Example

This script generates a list of possible authors from the internal docAuthors list:

<$optList docAuthors$>

This script generates a list of the options specified in the xRegion custom metadata field:

<$optList xRegion.options$>

This script generates an option list from the variable optionListName and specifies the default value:

<$if optionsAllowPreselect and fieldValue$>
    <$defaultOptionListScript = "<$optList " & optionListName & ":fieldValue$>"$>
<$else$>
    <$defaultOptionListScript = "<$optList " & optionListName & ":noselected$>"$>
<$endif$>

See Also