fbpx
Welcome, Guest
Username: Password: Remember me

TOPIC: Custom field type

Custom field type 1 year 1 month ago #29675

  • pfactory
  • pfactory's Avatar
  • Offline
  • New Member
  • Posts: 2
  • Karma: 0
Hi,

we are evaluating JD-Builder as the main editing system on some of our future sites.
One crucial feature we are looking for is the possibility to add custom field types when editing pages.

An example:
Defining a new element in JD Builder is easy: Just create the directory containing the php-files and the xml-file containing the field definitions.
But some of our data comes for instance from external databases or webservices ecc. for which we usually create a custom field type within Joomla, which create the dropdowns containing the possible options or something like that.
We tried to create a custom field type and add the containing directory to the elements xml:
<fields addfieldpath="/plugins/system/jdbuilder/fields">

But if used in the form xml, for instance like this:
<field type="cities".....

It simply does not show up.

Are we missing something or does JD Builder not support custom field types?

Thanks in advance
Best regards
The administrator has disabled public write access.

Custom field type 1 year 1 month ago #29740

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Posts: 4490
  • Thank you received: 647
  • Karma: 116
Hi,

It doesn't support custom fields right now but it's something we are working on and is coming up the line very soon.

Thanks,
Chetan
Thank You,
If you like our support and products, tweet us at joomdev and let the world know about it.
The administrator has disabled public write access.

Custom field type 1 year 1 month ago #29802

  • Sch
  • Sch's Avatar
  • Offline
  • Senior Member
  • Posts: 53
  • Thank you received: 7
  • Karma: 2
Why you don't write your own JD Element for sql queries?
I did it and it works fine.
The administrator has disabled public write access.
The following user(s) said Thank You: pfactory

Custom field type 1 year 1 month ago #29811

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Posts: 4490
  • Thank you received: 647
  • Karma: 116
I am sure you'll have in place. If you have written something and would like to share with others. Please post the details on this thread. sharing the code via github.
Thank You,
If you like our support and products, tweet us at joomdev and let the world know about it.
The administrator has disabled public write access.

Custom field type 1 year 1 month ago #29812

  • pfactory
  • pfactory's Avatar
  • Offline
  • New Member
  • Posts: 2
  • Karma: 0
What do you mean with JD Element for sql queries? Something you can reference from the form-xml?

Thanks!! :)
The administrator has disabled public write access.

Custom field type 1 year 1 month ago #29836

  • Sch
  • Sch's Avatar
  • Offline
  • Senior Member
  • Posts: 53
  • Thank you received: 7
  • Karma: 2
Hello,

of course I can share my solution.

You wrote that you want to fetch data from external databases. I don't know what kind of data this is, but if it's e.g. a small SQL query and you only want to output a text or a number, you can use my solution.
Note: This element is intended to output a text or a number (number of entries, for example) as text.

In JD it is possible to create your own element to use it for build up your pages.
I want to recomend following links for that:
Creating your first JD Builder Element
JD Builder Hello World Element

I create two elements of my own a "SQL-Query" for a simple output and a "SQL-Number-Counter" based on the original "Number-Counter" element with a sql query for the start and end number.

You need the following element structure based on the "sql-query" folder:
sql-query.xml
tmpl/default.js
tmpl/default.php
language/en-GB/en-GB.sql-query.ini

sql-query.xml
This defines the element structure for the input values (text, typography, color, ....).
Here we have basicly a input field for the query, a setup for the typo and a colorpicker for the fontcolor.
Warning: Spoiler! [ Click to expand ]

tmpl/default.js
The javascript file render the element in the backends page builder.
Warning: Spoiler! [ Click to expand ]

tmpl/default.php
The default.php is responsible for the output in the frontend.
Warning: Spoiler! [ Click to expand ]

en-GB.sql-query.ini
Here you can define the language labels for the xml file.
Warning: Spoiler! [ Click to expand ]

All you need is to copy the folder to JOOMLAROOT/plugins/system/jdbuilder/elements/.
If you want to add an icon for the backend, you need to upload suitable svg image to media/jdbuilder/images/icons/elements/ and link that into the xml file inside the <icon> brackets.

But there is a issue. It is not possible to render the sql query on the page builder at the backend.
Thats because the output is generatet by javascript and js can not handle php sql queries.
I guess it is possible to outsource the sql query in an external php file and get the query result by ajax and a post method.
Unfortunately, I have no experience with this and I have no idea about the security of the post method itself.
Last Edit: 1 year 1 month ago by Sch.
The administrator has disabled public write access.
Moderators: chandandeep
Time to create page: 0.385 seconds
Cron Job Starts