Dreamweaver users can format data with built-in formats. They can also create new formats that are based on built-in format types, or create new formats that are based on custom format types.

The user can format dynamic data in several ways. To format the data before inserting it into an HTML document, use the Format menu. It is in the Dynamic Data or the Dynamic Text dialog box or in the Bindings panel. To create a format, select the Edit Format List command from the Format menu and select a format type from the Plus (+) menu. The Plus (+) menu contains a list of format types. Format types are basic format categories, such as Currency, DateTime, or AlphaCase. Format types collect all the common parameters for a category of format, letting you streamline the work to create a format.

An example is to create a currency format. Currency formatting consists of converting a number to a string, inserting commas and decimal points, and inserting a currency symbol, such as a dollar ($) sign. The Currency format data type collects all the common parameters and prompts you for the required values.

The server format API discusses the API that formats the dynamic data that the functions described in Data sources return. The functions that are described in both topics work together to format dynamic data.

All format files reside in the Configuration/ServerFormats/currentServerModel folder. Each subfolder contains one XML file and multiple HTML files.

The Formats.xml file describes all the choices in the Format menu. Dreamweaver automatically adds the Edit Format List and None options.

The folder also contains one HTML file for each currently installed format type, which includes AlphaCase, Currency, DateTime, Math, Number, Percent, Simple, and Trim.

Note:

Currency format is not available for PHP server models.

The Formats.xml file

The Formats.xml file contains one format tag for each item in the Format menu. Each format tag contains the following mandatory attributes:

  • The file=fileName attribute is the HTML file for this format type, such as "Currency".

  • The title=string attribute is the string that appears in the Format menu, such as "Currency - default".

  • The expression=regexp attribute is a regular expression that matches the dynamic data objects that use this format. The expression determines what format is currently applied to a dynamic data object. For example, the expression for the "Currency - default" format is "<%\s*=\s*FormatCurrency\(.*, -1, -2, -2,-2\)\s*%>|<%\s*=\s*DoCurrency\(.*, -1, -2, -2, -2\)\s*%>". The value of the expression attribute must be unique among all format tags in the file; it must be specific enough to guarantee that only instances of this format match the expression.

  • The visibility=[hidden | visible] attribute indicates whether the value appears in the Format menu. If the value of the visibility attribute is hidden, the format does not appear in the Format menu.

The format tag can contain additional, arbitrarily named attributes.

Some data formatting functions require an argument, format, which is a JavaScript object. This object is the node that corresponds to the format tag in the Formats.xml file. The object has a JavaScript property for each attribute of the corresponding format tag.

The following example shows the format tag for the "Currency - default" string:

 <format file="Currency" title="Currency - default" ¬ 
expression="<%\s*=\s*FormatCurrency\(.*, -1, -2, -2, -2\)\s*%>|¬ 
    <%\s*=\s*DoCurrency\(.*, -1, -2, -2, -2\)\s*%>" 
NumDigitsAfterDecimal=-1 IncludeLeadingDigit=-2 ¬ 
    UseParensForNegativeNumbers=-2 GroupDigits=-2/>

The format type for this format is Currency. The "Currency - default" string appears on the Format menu. The expression <%\s*=\s*FormatCurrency\(.*, -1, -2, -2,-2\)\s*%>|<%\s*=\s*DoCurrency\(.*, -1, -2, -2, -2\)\s*%> finds occurrences of this format in the user’s document.

The NumDigitsAfterDecimal, IncludeLeadingDigit, UseParensForNegativeNumbers, and GroupDigits parameters are for the Currency format type and are not required. These parameters appear in the Parameters dialog box for the Currency format type. The Parameters dialog box appears when a user selects the Currency format type from the Plus (+) menu of the Edit Format List dialog box. The values that are specified for these parameters define the new format.

The Edit Format List Plus (+) menu

If you do not want a file in the ServerFormats folder to appear in the Edit Format List Plus (+) menu, add the following statement as the first line of the HTML file:

 <!-- MENU-LOCATION=NONE -->

To determine the contents of the menu, Dreamweaver first searches for a ServerFormats.xml file in the same folder as the data formats (for example, in Configuration/ServerFormats/ASP/). The ServerFormats.xml file describes the contents of the Edit Format List Plus (+) menu, and it contains references to the HTML files that it lists in the menu.

Dreamweaver checks each referenced HTML file for a title tag. If the file contains a title tag, the content of the title tag appears in the menu. If the file does not contain a title tag, the filename is used in the menu.

After Dreamweaver finishes searching for the file, or if the file does not exist, Dreamweaver scans the rest of the folder to find other items that should appear in the menu. If Dreamweaver finds files in the main folder that aren’t already in the menu, it adds them. If subfolders contain files that aren’t already in the menu, Dreamweaver creates a submenu and adds those files to it.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy