Pixel & Tonic

FieldFrame

version works on rated
1.4 EE1
Download Get Help

Functions Reference

There are a few things that most fieldtype extensions need to do: display field settings, display the field, and customize the template tag output. These are the key areas that FieldFrame aims to simplify.

Below is a list of the functions you can add to your fieldtype extension to accomplish these things.

Functions at a Glance

update()

Called when the fieldtype extension is first installed, or updated.

Arguments
$from
(string or bool) — previously-installed fieldtype version number, or FALSE if it’s a new install

display_site_settings()

Add site-wide settings to the Fieldtype Manager within FieldFrame’s settings

Returns

HTML to be inserted into your fieldtype’s Settings block within the Fieldtype Manager

save_site_settings()

Modify the site settings’ post data before it gets saved to the database.

Arguments
$site_settings
(array) — post data that came from any inputs you created in display_site_settings
Returns

Array with the modified post data

display_field_settings()

Add custom settings to the Edit Field form

Arguments
$field_settings
(array) — previously-saved field settings
Returns

Associative array with the following optional keys:

cell1
(string) — HTML to be inserted in the same cell as the Field Type select
cell2
(string) — HTML to be inserted in the cell to the right of the Field Type select
rows
(array) — additional rows to be inserted below the row with the Field Type select. Each element is a nested array with two elements which contain the HTML to be inserted in the left and right cells of a new row
formatting_available
(bool) — determines whether the “Default Text Formatting for This Field” setting block should be available (FALSE by default)
direction_available
(bool) — determines whether the “Text Direction” setting block should be available (FALSE by default)

save_field_settings()

Modify the field settings’ post data before it gets saved to the database.

Arguments
$field_settings
(array) — post data that came from any inputs you created in display_field_settings
Returns

Array with the modified post data

display_field()

Create the custom field HTML for the Publish form.

Arguments
$field_name
(string) — name you give your field input (e.g. “field_id_1”)
$field_data
(string) — previously-saved field data
$field_settings
(array) — the field settings
Returns

String of HTML to be inserted into the Publish form

save_field()

Modify the field’s post data before it gets saved to the database.

Arguments
$field_data
(mixed) — the field’s post data
$field_settings
(array) — the field settings
$entry_id
(mixed) — the entry ID (only passed if Postponed saving is enabled) — the entry’s ID, or FALSE if the user clicked Preview on a new entry
Returns

The modified post data

display_tag()

Modify the template tag output.

Note: This will get called in the same manner regardless of whether it’s being called for a field or an FF Matrix cell.

Arguments
$params
(array) — key/value pairs of the template tag parameters
$tagdata
(string) — contents of the template between the opening and closing tags, if it’s a tag pair
$field_data
(string) — the field data
$field_settings
(array) — the field settings

Beyond the arguments sent to display_field, there are a few helper variables temporarily attached to the global $FF object at the time it is called:

$FF->tagdata
(array) — the {exp:weblog:entries} tag data sent by the weblog_entries_tagdata hook
$FF->row
(array) — the current entry data sent by the weblog_entries_tagdata hook
$FF->weblog
(object) — the current Weblog object sent by the weblog_entries_tagdata hook
$FF->field_id
(object) — the field’s ID
$FF->field_name
(object) — the field’s name

You can access any of these variables like so:

global $FF;
$field_id = $FF->field_id;
Returns

String of template markup