Extensions

An extension allows you to change the template to support additional feature(s) implemented in the extension. Extensions files must be placed under the subfolder "extensions" of the installation folder.

Note The PHP API extension shipped with DB AppMaker is a special extension which is placed under the subfolder "template" folder so that it can be generated as a template instead of as an extension for a template. That is a special case, all other extensions should be placed in the "extensions" subfolder.

 

Using Extensions

Click Tools->Extensions to enable or disable these extensions. Before enabling the extension, make sure you read the notes about the extension first. If the extension has advanced settings (NOT every extension has it), you'll see the Advanced tab after selecting the extension. Click the Advanced to configure advanced settings for the extension.

In the Advanced tab, you may see Project, Tables, and Fields tabs, depending on extensions.

Notes

  1. NOT every extension has all 3 tabs, an extension may have project level settings only.
  2. If there are table or field level settings, the table or field names in the Tables or Fields tabs are searchable, to find a table or field, just focus the Table or Field column by clicking the column first and then type the table or field name.

 

 

Making Extensions

It is simple to make your own extensions. Each extension has an XML description file so the product can load it in the user interface for setting up. You can open an XML file in the "extensions" subfolder to see the content. The XML file has the following structure:

<?xml version="1.0" encoding="iso-8859-1" ?>
<ew-extension name="ExtensionName" version="x.x.x" type="Extension Type" author="Author Name">
<description>
<![CDATA[
Description of the extension
]]>
</description>
<file>xxx.zip</file>
<Project>
    <Attribute name="AttributeName" type="DataType" default="xxx" />
    ...
    <Database>
        <Table>
            <Attribute name="AttributeName" type="DataType" default="xxx" />
            ...
            <Field>
                <Attribute name="AttributeName" type="DataType" default="xxx" />
                ...
            </Field>
        </Table>
    </Database>
</Project>
<control ... />
...
</ew-extension>

<ew-extension> The root node of the XML file, it contains information of the extension to be shown by the user interface.
<description> Description of the extension. Shown as "Notes" in the user interface.
<file> Zip file for the extension. (Optional)

Note The zip file name must contain alphanumeric characters only (no special characters and no spaces) and must be in lower case.

The zip file contains sub-template files to change a sub-template of the same file name in the main template.

To append code to a sub-template in the main template, add a file with the same name.

To clear generated code of the original sub-template first and then replace with your own, add the following as the first line in your sub-template:

<# args.code = ""; #>

To generate additional files, use <control> tag (see below).

<Attribute>

Optional. Properties of the extension. You can add multiple <Attribute> tags inside <Project>, <Table> and/or <Field> tag.

If the <Attribute> tag is enclosed by <Project> tag, the attribute is project level, similarly for table and field level attributes.

Make sure you set unique attribute name for each attribute. The attribute name should contain alphanumeric characters only and should not start with digit.

The type attribute specifies the data type of the value. Support types are: "Boolean", "Integer" and "Color". Others are considered as string.

The optional default attribute specifies a default value for the setting.

<control> Optional. Additional files to be generated. Same as <control> tags in Control File. You can add multiple <control> tags for an extension.

In your extension, you can get the extension properties as as follows:

<#
let projAttr, tableAttr, fieldAttr; // Declare your variables
let ext = GetExtensionObject("ExtensionName"); // Get extension object by extension name
if (ext && ext.Enabled) { // If extension enabled
    projAttr = ext.PROJ.AttributeName; // Get project level attribute value by attribute name
    ...
    if (TABLE) { // If you have table level settings
        let extTable = GetExtensionTable(extName, TABLE.TblName);
        if (extTable) {
            tableAttr = extTable.AttributeName; // Get table level attribute by attribute name
            ...
            for (let f of allFields) { // If you have field level settings, loop all fields
                let extField = GetExtensionField(extName, TABLE.TblName, f.FldName);
                if (extField) {
                    fieldAttr = extField.AttributeName; // Get field level attribute by attribute name
                    ...
                }
            }
        }
    }
}
#>

 

Note See the XML description files of the extensions, or Custom View/Edit Tags and unzip the zip file (if any) to see the source code as examples.

 

 

Also See

Control File
Template Tags
Object Properties
Third-party Tools



 

 ©2016-2021 e.World Technology Ltd. All rights reserved.