Skip to content

Customize Astroid Template Options

Priya Singh edited this page Dec 14, 2018 · 2 revisions

Within an Astroid template, there are template options files (XML) to manage all template options. These files include the information of parameters as well as tabs and field grouping. These files, allowing you to manage the full power of the Astroid Template!

Adding Template Options

In order to add custom template options create an xml file at JOOMLA_ROOT/templates/YOUR_ASTROID_TEMPLATE/astroid/options

Naming XML

The name of XML can be anything but XML with the same name of the template will be preferable to prevent it from accidental update confliction. eg. If you are using astroid_template_zero then XML filename zero.xml is preferable. You file should look like below:

JOOMLA_ROOT/templates/YOUR_ASTROID_TEMPLATE/astroid/options/YOUR_XML_FILE.xml

Syntax

Structure of XML

The primary tag of the file is:

<?xml version="1.0" encoding="UTF-8"?>
<form>
   <fields name="params">
        YOUR TEMPLATE OPTIONS
   </fields>
</form>

Adding new tab in Template Options Area

In order to create a new tab, you can use <fieldset> tag.

<fieldset
    label="CUSTOM_TEMPLATE_OPTIONS"
    icon="CUSTOM_TEMPLATE_OPTIONS_ICON_CLASS"
    name="CUSTOM_TEMPLATE_OPTIONS"
    addfieldpath="/libraries/astroid/framework/fields"
    order="CUSTOM_TEMPLATE_OPTIONS_ORDER">
        YOUR FIELDS WILL BE HERE
</fieldset>

Additionally, each <fieldset> item can define the following attributes:

Attribute Description
label Required - Title/Label of Tab
name Required - A unique name(id) for tab
addfieldpath Required - In order to use Astroid framework's fields
icon Optional - Icon class, To display an icon with tab Title/Label
order Optional - To set tab order/position in the template options area

Grouping Fields in Tab

In order to group fields, First create a field using <field> tag with the type=astroidgroup attribute.

<field
    type="astroidgroup"
    name="UNIQUE_GROUP_NAME"
    title="FIELD_GROUP_TITLE"
/>

And Add field(s) by using astroidgroup="UNIQUE_GROUP_NAME" attribute to the field(s).

<field
    astroidgroup="UNIQUE_GROUP_NAME"
    name="FIELD_UNIQUE_NAME"
    type="FIELD_TYPE"
    label="FIELD_LABEL"
/>

Adding Fields into existing tab

In order to add field(s) in existing tab simply copy the same <fieldset> tag code from exiting option file in which you want to add more options as shown in this example:

<?xml version="1.0" encoding="UTF-8"?>
<form>
   <fields name="params">
      <fieldset
          label="ASTROID_OPTIONS_BASIC"
          icon="fas fa-home"
          name="basic"
          addfieldpath="/libraries/astroid/framework/fields"
          order="1">
             <field
                 type="astroidgroup"
                 name="UNIQUE_GROUP_NAME"
                 title="FIELD_GROUP_TITLE"
             />

             <field
                 astroidgroup="UNIQUE_GROUP_NAME"
                 description="FIELD_DESCRIPTION"
                 name="FIELD_NAME"
                 type="FIELD_TYPE"
                 label="FIELD_LABEL"
             />
      </fieldset>
   </fields>
</form>

This example will add a new field group in the Basic options tab. Check out the full list of Astroid Field Types