Development Guide
Field-Type Plugins
A Field-Type plugin allows you to customize ILIAS DataCollections by extending the existing list of possible field-types. You are now able to introduce a new types by configuring its representation and behavior, or setting restrictions.
Plugin Slot
This plugin slot is part of the component "DataCollection" and is called "FieldTypeHook". Therefore plugins of this type have to be installed in the designated ILIAS folder:
- ILIAS 9 and lowerCustomizing/global/plugins/Modules/DataCollection/FieldTypeHook
- ILIAS 10 and higher public/Customizing/plugins/DataCollection/FieldTypeHook
Directory Structure
A plugin must have the following minimum directory structure:
- PluginName
- classes
- class.ilPluginNamePlugin.php
- class.ilPluginNameFieldModel.php
- class.ilPluginNameFieldRepresentation.php
- class.ilPluginNameRecordFieldModel.php
- plugin.php
- classes
A plugin may have optional structure like:
- PluginName
- setup
- ...
- lang
- ilias_en.lang
- ...
- README.md
- setup
Code examples
All PHP files of the plugin must follow the current ILIAS PRS code style. The README.md od the plugin must support the current Markdown standard.
Further you can find some examples/templates for plugin files:
plugin.php
All plugins must include a plugin.php file.
<?php declare(strict_types=1); |
class.ilExamplePluginPlugin.php
The function `getStorageLocation()` will define wich storage will used to save the field data of the plugin. Per default the data will be saved as text (1). It can also be save as integer (2) or datetime (3) or you can implement and define an own storage (0) wich you handle yourself.
<?php declare(strict_types=1); |
The plugin class must inherit from ilDclFieldTypePlugin. It suffices to overwrite the method to receive the plugins name here.
class.ilExamplePluginFieldRepresentation.php
The function `getInputField()` will define the presentation of the input within the form of a new/edit entry. The provided input must be supported by the ILIAS property form.
<?php declare(strict_types=1); |
This are the lowest requirements to make a plugin work. If you want to make furthe and more distinct adaptions within you plugin data you can do that by overwriting the functions of all classes within the plugin.
- ...Plugin.php handles the generall processing of your fields and acces of you plugin in all occurences.
- ...FieldModel.php handles the field settings and configurations, like sorting or requirements.
- ...FieldRepresentation.php handles the presentation of your plugin fields data concerning editing and creation.
- ...RecordFieldModel.php handles the presentation of your plugin fields data within content.
If you want to change your plugins presentation within the selection of field types when creating a new field, you can do that by providing 2 language variables within your `lang` files:
- field_type_name to change the displayed title of the field.
- field_type_info to change/add a byline to the field.