jDiction Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

jDiction 2.2.0 released. http://jdiction.org/downloads

Author Topic: XML Specification  (Read 23871 times)

Harald Leithner

  • Administrator
  • Hero Member
  • *****
  • Posts: 1684
    • View Profile
XML Specification
« on: August 01, 2014, 04:16:48 pm »

This is the documentation for the xml File used by jDiction to support 3rd party extensions.

Thx to pagchen and pipedream for creating most part of this post.


A jdiction.xml file should be created inside administrator/components/com_<COMPONENT>/.

Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<jdiction>
  <component>com_<COMPONENT></component>
  <sections>
    <section>
      <tables>
        <table>
          <name>#__db_table</name>
          <key>db_table_key</key>
          <class><COMPONENT>Table</class>
          <file><COMPONENT>.php</file>
          <cache fullfetch="0" />
          <exportfilter/>
        </table>
      </tables>
      <views>
        <view name="edit_view" list="list_view" layout="edit_layout" default="true">
          <form import="<FORM>.xml">
            <fieldset name="main" label="COM_JDICTION_TRANSLATION_FIELDSET_MAIN">
              <field name="<A_FIELD>" />
   <field name="<ANOTHER_FIELD>" />
            </fieldset>
            <fields name="extra_fields">
              <fieldset name="extra" label="ANOTHER_TRANSLATION_STRING">
                <field name="an_extra_field" />
              </fieldset>
            </fields>
          </form>
        </view>
      </views>
    </section>
  </sections>
</jdiction>

<tables> tag

Locate the model file, such as administrator/components/com_<COMPONENT>/tables/<TABLE>.php.
The <table><file> tag should contain the name of this file and in its content we can also find the values for the tags:
  • <table><class>, within the code "class <COMPONENT>Table extends JTable";
  • <table><name>, within the code "parent::__construct('#__db_table', 'db_table_key', $db);";
  • <table><key>, within the code "parent::__construct('#__db_table', 'db_table_key', $db);".
<table><cache> should have the attribute fullfetch equal to 0 unless we are sure that all the table records are always being fetched by Joomla.

The tag <table><exportfilter> is optional and allows you to filter records through an SQL query when exporting the table.

<views> tag

In you administrator's panel visit the component and get the view/task and layout values of the URL of the listing and editing pages.
The <view> tag should have the following attributes:
  • name, value of the view/task parameter in the editing URL:
    "/administrator/index.php?option=<COMPONENT>&view=edit_view" or
    "/administrator/index.php?option=<COMPONENT>&task=edit_view.edit_layout";
  • list, value of the view/task parameter in the listing URL:
    "/administrator/index.php?option=<COMPONENT>&view=list_view" or
    "/administrator/index.php?option=<COMPONENT>&task=list_view.list_layout";
  • layout, value of the layout parameter in the editing URL:
    "/administrator/index.php?option=<COMPONENT>&task=edit_view.edit_layout" or
    "/administrator/index.php?option=<COMPONENT>&task=edit_view&layout=edit_layout"
    (if the layout parameter is not defined, the value "default" should be used);
  • default, when equal to true it should allow translations on the default component page (without any view/task parameter defined, such as "administrator/index.php?option=<COMPONENT>), seems to be useful only when the default task is not the editing or listing because for these it would be enough to specify as "default" its attribute (name or list, respectively).
The attribute import of the tag <view><form> accepts XML files (separated by commas) that define forms created using JForm in the administrator/components/com_<COMPONENT>/models/forms/ folder. When importing these form definitions, we don't have to specify each attribute of the field tags beyond the name attribute, unless we want to change attribute values or specify additional attributes.

Regarding the fieldset, fields and field tags, these should follow what is described in Joomla! Documentation:
http://docs.joomla.org/XML_JForm_form_definitions
NOTE: there are some things missing in Joomla documentation, such as:
- in order to avoid that HTML from an Editor form field type is filtered, it is necessary to add the attribute filter="JComponentHelper::filterText"

Still, there are some aspects worth mentioning:
  • fieldset tag must have a name attribute and, if a XML form definition file is imported, its value or the value of an additional attribute named reffield should be the same as the one set in the file;
  • field tag can have an alias auto-generated from another field by setting the following attributes and values: type="jdalias" and field="source_field_name" (usually source_field_name is "title");
  • export of a particular field can be disabled if its attribute export is equal to "false";
  • field tag can accept a pair of attributes for holding multiple table columns: the multifield attribute holds the column names (separated by commas) and the seperator attribute defines what separates each column value inside the field; for now, this feature seems to only work with the Joomla content table;
  • fields tag can be used for handling multiple fields stored as a JSON format string in a single table column.


« Last Edit: January 23, 2015, 12:16:23 pm by Harald Leithner »
Logged
Joomla! 5.0 Release Manager
Vote at JED