jDiction Forum

English => Extensions and jDiction => Topic started by: pagchen on February 06, 2014, 07:52:21 pm

Title: XML format for component
Post by: pagchen on February 06, 2014, 07:52:21 pm
Hi,
I am building a custom component and wanted to create an xml file so my component is using jdiction powerful translation.
I did find bits in many places, so I thought I would combine all the info I gathered here.

First you need to create a file called jdiction.xml in the administration folder (administrator/components/my_component/jdiction.xml)

The format to use is like this:
Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<jdiction>
  <component>com_mycomponent</component>
  <sections>
    <section>
      <tables>
        <table>
          <name>#__mycomponent_items</name>
          <key>id</key>
          <class>mycomponentTableItem</class>
          <file>item.php</file>
          <cache fullfetch="1" />
        </table>

      </tables>
      <views>
        <view name="item" list="items" layout="edit" default="true">
          <form import="form.xml">
          <fieldset name="main" label="COM_JDICTION_TRANSLATION_FIELDSET_MAIN">
              <field name="title" />
      <field name="otherfields" />
          </fieldset>
          </form>
        </view>
      </views>
    </section>
<section>
<tables>
<table>
  <name>#__mycomponent_otheritems</name>
  <key>id</key>
  <class>mycomponentTableOtheritem</class>
  <file>otheritem.php</file>
  <cache fullfetch="1" />
</table>
</tables>
<views>
<view name="otheritem" list="otheritems" layout="edit" default="true">
  <form import="form.xml">
  <fieldset name="main" label="COM_JDICTION_TRANSLATION_FIELDSET_MAIN">
  <field name="title" />
  <field name="otherfields" />
</fieldset>
  </form>
</view>
</views>
</section>
  </sections>
</jdiction>

So basically, you need to put each table in its section, change the name of the tables and component. Adjust the view names. Put the primary key of the table in the key field.
I still have to discover what the cache fullfetch is doing.

Cheers,
Title: Re: XML format for component
Post by: Harald Leithner on February 09, 2014, 02:19:09 pm
Hi pagchen,

I should really start to write a documentation (I already did start but stopped because I didn't have the time :-()

thx for your start.
The "fullfetch" option means that all translation for this table getting loaded by the first time a item get requested, this is useful for the #__menu table for example because I know that this table will always be loaded completely because Joomla needs it.

thx
Title: Re: XML format for component
Post by: pipedream on July 11, 2014, 06:08:54 am
Hi Harald,

Yes, please complete the documentation.

While using jDiction with Event Booking, I had some problems trying to find the correct values for each tag and parameter.
So, I will try my best to add something to the useful information already posted by pagchen.

A jdiction.xml file should be created inside administrator/components/com_my_component/.

Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<jdiction>
  <component>com_my_component</component>
  <sections>
    <section>
      <tables>
        <table>
          <name>#__db_table</name>
          <key>db_table_key</key>
          <class>MyComponentTable</class>
          <file>my_component.php</file>
          <cache fullfetch="0" />
          <exportfilter/>
        </table>
      </tables>
      <views>
        <view name="edit_view" list="list_view" layout="edit_layout" default="true">
          <form import="my_component_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_my_component/tables/my_component.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:
As far I understood, <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. Don't know if this tag is mandatory.

The tag <table><exportfilter> seems to be optional and allows you to filter records through an SQL query when exporting the table, right?

<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:
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_my_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

Still, there are some aspects worth mentioning:


Please review and correct this information, thanks.