Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Customfields API
#1
What must a plugin do to insert its own field(s) to the customfields.xml file? Any recommended way?
Reply
#2
...or maybe I should have asked first:

Might plugins use CustomFields for their own fields?
Or is it better to leave that for user-created fields only, and keep adding the fields the usual way? (using changedata-save and edit-extras hooks)
Reply
#3
Carlos Wrote:What must a plugin do to insert its own field(s) to the customfields.xml file? Any recommended way?

Carlos Wrote:...or maybe I should have asked first:

Might plugins use CustomFields for their own fields?
Or is it better to leave that for user-created fields only, and keep adding the fields the usual way? (using changedata-save and edit-extras hooks)

Sorry for answering late - I was on vacation.
Assuming you are using the I18N Custom Filelds plugin:
  • The fields in customfields.xml are displayed to the user, when he edits the page
  • However, any other fields you add to a page during changedata-save can also be accessed using get/return_custom_field (e.g. the field creDate put there by the plugin itself.
  • There is no function to write to customfields.xml - you have to read/modify/write the file yourself in your plugin (and check if the field is already there, ...)
  • If you want to use a custom field in your plugin, you can ask the user to add it - like the I18N plugin "if you want to have external links, add a custom field link and ...". Then check it in your plugin:
Code:
if (function_exists('return_custom_field')) { // I18N Custom Fields installed?
  $field = return_custom_field('my_field','default');
  ...
}
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply




Users browsing this thread: 1 Guest(s)