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 for custom made params  (Read 20014 times)

nkt

  • Newbie
  • *
  • Posts: 24
    • View Profile
    • Flantic
XML for custom made params
« on: April 29, 2014, 04:11:03 pm »

Hi all,

I made a plugin that adds extra parameters to the category detail view in the backend. It adds the following XML file stored in the plugin folder to the form:
Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="params">
<fieldset name="FILTER">
<field name="filter_exptag" type="checkbox" label="PLG_CONTENT_CATFILTER_EXPTAG" value="1" default="0" />
<field name="namefilter1" type="text" label="PLG_CONTENT_CATFILTER_TEXT" description="PLG_CONTENT_CATFILTER_TEXT_DESC" size="30" />
<field type="spacer" name="myspacer1" hr="true" />
<field name="filter_relexp" type="checkbox" label="PLG_CONTENT_CATFILTER_RELEXP" value="1" default="0"/>
<field name="namefilter2" type="text" label="PLG_CONTENT_CATFILTER_TEXT" description="PLG_CONTENT_CATFILTER_TEXT_DESC" size="30" />
<field type="spacer" name="myspacer2" hr="true" />
<field name="filter_relsec" type="checkbox" label="PLG_CONTENT_CATFILTER_RELSEC" value="1" default="0"/>
<field name="namefilter3" type="text" label="PLG_CONTENT_CATFILTER_TEXT" description="PLG_CONTENT_CATFILTER_TEXT_DESC" size="30" />
</fieldset>
</fields>
</form>
The problem is that I won't succeed in translating these custom params. I tried the following for categories.xml and many variations:
Code: [Select]
<?xml version="1.0" encoding="utf-8"?>
<jdiction>
  <component>com_categories</component>
  <sections>
    <section>
      <tables>
        <table>
          <name>#__categories</name>
          <key>id</key>
          <class>CategoriesTableCategory</class>
          <file>category.php</file>
          <exportfilter>title != "ROOT"</exportfilter>
          <cache fullfetch="1" />
        </table>
      </tables>
      <views>
        <view name="category" list="categories" layout="edit" default="true">
          <form import="category.xml">
          <fieldset name="main" label="COM_JDICTION_TRANSLATION_FIELDSET_MAIN">
              <field name="title" />
              <field name="alias" type="jdalias" field="title" export="false" />
              <field name="metakey" />
              <field name="metadesc" />
              <field name="description" />
            </fieldset>
          </form>
  <form import="..\..\..\..\..\plugins\content\catfilter\catfilter.xml">
          <fieldset name="FILTER" label="COM_JDICTION_TRANSLATION_FIELDSET_MAIN">
              <field name="namefilter1" />
            </fieldset>
          </form>
        </view>
      </views>
    </section>
  </sections>
</jdiction>

To make it more clear, I added my plugin.
Logged

Harald Leithner

  • Administrator
  • Hero Member
  • *****
  • Posts: 1688
    • View Profile
Re: XML for custom made params
« Reply #1 on: April 29, 2014, 04:31:36 pm »

Nice work.

thx for sharing.
Logged
Joomla! 5.0 Release Manager
Vote at JED

nkt

  • Newbie
  • *
  • Posts: 24
    • View Profile
    • Flantic
Re: XML for custom made params
« Reply #2 on: April 29, 2014, 04:42:19 pm »

Thnx Harald, however I still got the problem that I can't translate my custom parameters :'(

Do you have an idea how to edit the categories.xml, such that it will also translate my custom parameters?
Logged

Harald Leithner

  • Administrator
  • Hero Member
  • *****
  • Posts: 1688
    • View Profile
Re: XML for custom made params
« Reply #3 on: April 29, 2014, 05:20:21 pm »

sure ;-)

you have to enclose the fieldset with a field tag

Code: [Select]
<fields name="params">
  <fieldset name="FILTER" label="COM_JDICTION_TRANSLATION_FIELDSET_MAIN">
    <field name="namefilter1" />
  </fieldset>
</fields>
Logged
Joomla! 5.0 Release Manager
Vote at JED

nkt

  • Newbie
  • *
  • Posts: 24
    • View Profile
    • Flantic
Re: XML for custom made params
« Reply #4 on: April 29, 2014, 05:27:55 pm »

Unfortunately that doesn't work, the field doesn't even show up in the translation form.

And why do I need to enclose it in the fields tag, because the "main" fieldset is also not enclosed by a fields tag.

Thanks for helping me!
Logged

Harald Leithner

  • Administrator
  • Hero Member
  • *****
  • Posts: 1688
    • View Profile
Re: XML for custom made params
« Reply #5 on: April 29, 2014, 05:48:21 pm »

because your fields are saved in the database column "params".

are they showing up without fields? if not remove the second form-tag and include your complete xml in the first one.

jdiction merges the two xml files, so you can simply copy your data.
Logged
Joomla! 5.0 Release Manager
Vote at JED

nkt

  • Newbie
  • *
  • Posts: 24
    • View Profile
    • Flantic
Re: XML for custom made params
« Reply #6 on: April 29, 2014, 06:09:13 pm »

The field shows up when I include it in the same form tag, however it looses the link with the original language as the tip(popup) content is empty.

Tonight I will work on it more. If you have another good idea, please let me know!
Logged

Harald Leithner

  • Administrator
  • Hero Member
  • *****
  • Posts: 1688
    • View Profile
Re: XML for custom made params
« Reply #7 on: April 29, 2014, 09:18:03 pm »

look at the menu.xml its the same.
Code: [Select]
<fields name="params">
  <fieldset name="FILTER" label="COM_JDICTION_TRANSLATION_FIELDSET_MAIN">
    <field name="namefilter1" />
<field name="namefilter1" type="text" label="PLG_CONTENT_CATFILTER_TEXT" description="PLG_CONTENT_CATFILTER_TEXT_DESC" size="30" />
<field name="namefilter2" type="text" label="PLG_CONTENT_CATFILTER_TEXT" description="PLG_CONTENT_CATFILTER_TEXT_DESC" size="30" />
<field name="namefilter3" type="text" label="PLG_CONTENT_CATFILTER_TEXT" description="PLG_CONTENT_CATFILTER_TEXT_DESC" size="30" />
  </fieldset>
</fields>

try this code.
Logged
Joomla! 5.0 Release Manager
Vote at JED

nkt

  • Newbie
  • *
  • Posts: 24
    • View Profile
    • Flantic
Re: XML for custom made params
« Reply #8 on: April 30, 2014, 01:36:17 pm »

Hi Harald,

I came to the conclusion that the translation part already worked for this code:
sure ;-)

you have to enclose the fieldset with a field tag

Code: [Select]
<fields name="params">
  <fieldset name="FILTER" label="COM_JDICTION_TRANSLATION_FIELDSET_MAIN">
    <field name="namefilter1" />
  </fieldset>
</fields>

However what confused me is that the tiptext in the admin screen stays empty.

This caused by the fact that
Code: [Select]
$this->original in jform_25.php(view) contains the following:
Code: [Select]
title = 'Onderzoek'
alias = 'onderzoek'
metakey =
metadesc =
description =
params = '{"category_layout":"","image":"","filter_exptag":"1","namefilter1":"Ik zoek een onderzoeksmethode voor:","namefilter2":"","namefilter3":""}'
jd_sourcehash ='...'

Next in your code it is searching for the item called "namefilter1", however it will not find it, because it is placed under "params" as a json code.
I'll try to code it such that it takes the json variables and put them as items in the object.

PS above problem also holds for the menu params created by the menu.xml and for the alternative read more of a article.
« Last Edit: April 30, 2014, 01:46:05 pm by nkt »
Logged

Harald Leithner

  • Administrator
  • Hero Member
  • *****
  • Posts: 1688
    • View Profile
Re: XML for custom made params
« Reply #9 on: April 30, 2014, 01:50:13 pm »

Correct I know the problem (but didn't have time to fix it)
Logged
Joomla! 5.0 Release Manager
Vote at JED

nkt

  • Newbie
  • *
  • Posts: 24
    • View Profile
    • Flantic
Re: XML for custom made params
« Reply #10 on: April 30, 2014, 02:03:54 pm »

No problem! Thanks for all the help anyway!

If I have some lost hours one of these weeks, I will try to fix it for you.
Logged