2.8 Scoped Local Variables

Scoped local variables are a special kind of local variable, used to override how metadata is drawn to the page. These variables are scoped to a specific metadata field by separating them with a colon.

For example, to hide the title and comments fields, you would set the following flags:

dDocTitle:isHidden=1
xComments:isHidden=1

These flags must be set early in the page in the URL or by overriding the include std_doc_page_definitions.

In the following list, all flags affect the display of the field xFieldName:

  • xFieldName:groupHeader: This is set in Content Profiles if this field is the first field in a group. It contains the HTML and IdocScript to use for the group header.

  • xFieldName:hasOptionList: Allows the field to contain a custom option list, instead of using the default option list. Must be used with the xFieldName:optionListName variable or xFieldName:optionListScript variable.

  • xFieldName:include: Used to set the value for fieldInclude to the name of a custom resource include. This resource will be used throughout the page, including the JavaScript and the HTML. This flag is used rarely. If needed, use the std_namevalue_field include file as a guide for making a custom include.

  • xFieldName:isExcluded: Set to true to exclude a field from the page completely. It will not be displayed as a field, or as a hidden input field. The field will be completely absent from the page.

  • xFieldName:isHidden: Set to TRUE to hide a field on the page. On pages with form posts, the field will still be present. However, it will only exist as a hidden INPUT field. The value of the field will be blank, unless xFieldName or fieldValue is defined. This will enable you to create pages with default values that cannot be changed.

  • xFieldName:isInfoOnly: Set to TRUE to display only the value of a field. This is used instead of xFieldName:isHidden to show the user what default values are being submitted.

  • xFieldName:isRelocated: Set to TRUE to stop the automatic display of a field on the HTML page. By default, all fields on the page have a specific order. To reorder them, you must set this flag, then display the field manually.

    <!-- hide the comments field -->
    <$xComments:isRelocated = 1$>
    <$loop DocMetaDefinition$>
    <$strTrimWs(inc("std_meta_field_display"))$>
    <$endloop$>
    <!-- now turn off relocation, and display it -->
    <$xComments:isRelocated = ""$>
    <$fieldName="xComments", fieldCaption="Comments", fieldType="Memo"$>
    <$include std_display_field$>
    
  • xFieldName:isRequired: Set to TRUE to turn this field into a required field. This flag must be set in std_doc_page_definitions, before the JavaScript validation code is drawn to the page.

  • xFieldName:maxLength: Similar to fieldWidth, this sets the maximum length of a text input field. This is usually greater than fieldWidth, and must be less than the width of the field in the database.

  • xFieldName:noSchema: Set to TRUE to disable a schema option list for a field. Required if you want to generate option lists in a custom, dynamic way.

  • xFieldName:optionListName: This flag can only be set if a field is an option list. You can override which option list to use to display values:

    <$xCountry:hasOptionList = 1$>
    <$xCountry:noSchema = 1$>
    <$xCountry:optionListName = "securityGroups"$>
    <$loop DocMetaDefinition$>
    <$strTrimWs(inc("std_meta_field_display"))$>
    <$endloop$>
    
  • xFieldName:optionListScript: Similar to optionListName, except it can be used to render IdocScript instead of explicitly defined option lists. This allows the option list to be drawn with a ResultSet instead:

    <$xCountry:hasOptionList = 1$>
    <$xCountry:noSchema = 1$>
    <$xCountry:optionListScript =
    "<$rsMakeFromList('GROUPS', 'securityGroups')$>" &
    "<select>\n" &
    "<$loop GROUPS$>" &
    " <option><$row$>" &
    "<$endloop$>\n" &
    "</select>"$>
    <$loop DocMetaDefinition$>
    <$strTrimWs(inc("std_meta_field_display"))$>
    <$endloop$>
    
  • xFieldName:rowClass: Used in std_nameentry_row. It sets a Cascading Style Sheet class for the table row that contains this field.

    <$xComments:rowClass="xuiPageTitleText"$>
    <$loop DocMetaDefinition$>
    <$strTrimWs(inc("std_meta_field_display"))$>
    <$endloop$>
    
  • xFieldName:rowStyle: Same as rowClass, but this can be used to create inline styles. For example, to hide the Comments field with DHTML, use the following code:

    <$xComments:rowStyle="display:none"$>
    <$loop DocMetaDefinition$>
    <$strTrimWs(inc("std_meta_field_display"))$>
    <$endloop$>
    

    This is useful when you want to hide and display fields dynamically without a page reload.