When a HTTP client requests a folder URL that it has permission to list and the file-explorer is disabled, CompleteFTP will return a listing in HTML. The format of this listing is controlled by a template that may be modified. The template is defined by a single HTML page containing macros (see the 'Template Format' section below).
The template is modified using an editor that features real-time previews. Clicking on the ellipsis (...) in the Listing template property displays this editor, shown below.
The HTML to be used for the folder listing is entered on the left. On the right are shown the rendered HTML, and the generated HTML (i.e. with macros expanded). Macros may be entered manually or inserted by clicking the 'Insert macro' link at the bottom. The 'Reset to default' link may be clicked to set the template back to CompleteFTP's default format.
The template is split into three sections: the header, the entry-block and the footer. The header is everything before the %EntryBegin% macro; the entry-block is everything between %EntryBegin% and %EntryEnd%; and the footer is everything after %EntryEnd%. When a folder-listing is rendered the entry-block is repeated once for each entry in the folder. An entry can be a file or a sub-folder.
The table below defines the available macros as well as stating which section each macro may be used in:
Macro | Section | Description |
---|---|---|
%EntryBegin% | Start of entry-block | Marks the start of a block that defines the format of a single entry in the listing - file or folder |
%EntryEnd% | End of entry-block | Marks the end of a block that defines the format of a single entry in the listing - file or folder |
%FileCreated% | Entry-block | Date and time at which the file or folder was created |
%FileGroup% | Entry-block | Group of the folder or file |
%FileLength% | Entry-block | Length of the file in bytes, kB, MB or GB |
%FileModified% | Entry-block | Date and time at which the file or folder was last modified |
%FileName% | Entry-block | Name of the file or folder (not including the path) |
%FileOwner% | Entry-block | Owner (user) of the folder or file |
%FilePath% | Entry-block | Full virtual file-system path of file or folder |
%FilePermissions% | Entry-block | UNIX-like permission string of the file or folder |
%FileType% | Entry-block | Type of the directory-entry - either 'File' or 'Folder' (useful for CSS classes) |
%FolderName% | Header or footer | Name of the folder being listed |
%FolderPath% | Header or footer | Full virtual file-system path of the folder being listed |
%TimeZoneName% | Header or footer | Name of the current time-zone |
%TimeZoneOffset% | Header or footer | Offset (in hours) of the current time-zone compared to UTC |
Formatting instructions may be provided with each macro to refine how it is rendered. These instructions use a syntax similar to the composite formatting syntax defined by Microsoft. The general pattern is:
%macro-name[,alignment][:formatString]%
where macro-name is the name of the macro as shown in the table above or plain text (see below); alignment is an integer defining the preferred width of the field (positive=left-aligned, negative=right-aligned); and formatString provides instructions on how the text is formatted. These instructions depend on whether the field's type is a date or a number.
The functions, Max(m) and Pad(m), may be placed in a format-string. m is the name of an entry-block macro, such as FileName. Max(m) returns the maximum width of the field, m. Pad(m) returns the difference between the maximum and minimum widths of the field, m.
If the text that is not a legal macro-name is provided then that text is rendered literally. If no macro-name is provided then spaces will be inserted according to the alignment format. For example, ,Max(FileName) will insert a number of spaces equal to the longest file-name.
The following example produces a listing similar to the default listing format of Apache: