Instead of making a variable type, you can also choose to create or modify a custom fieldtype. In order to add Low Variables support to your fieldtype, just create it like you normally would, using Pixel & Tonic’s FieldFrame v1.4.3+ for EE1, or EE2’s Fieldtype API. Then, all you need to do is add a couple of methods to your fieldtype class. It’s a lot like adding Matrix support.
Displays the input field on the module home page. You can access the current variable id with $this->var_id
.
$var_name
(string, EE1 only) — The name used for the input field.$var_data
(string) — The current variable data.$var_settings
(array, EE1 only) — The current variable’s settings.
A string containing the HTML to be used in the module’s home page.
If the fieldtype has settings, use this method to display them. You can access the current variable id with $this->var_id
.
$var_settings
(array) — The current variable’s settings.
An array containing two elements: the name/label in the first element, the form element(s) in the second.
Use this method to catch the settings values before saving them to the database. You can access the current variable id with $this->var_id
.
$var_settings
(array) — The posted variable’s settings.
An associative array containing the settings to be saved.
Use this method for additional processing when a (new) variable has been saved to the database. You can access the current variable id with $this->var_id
.
$var_settings
(array) — The posted variable’s settings.
NULL
Use this method to catch the variable value before saving it to the database. You can access the current variable id with $this->var_id
.
$var_data
(string) — The posted variable data.$var_settings
(array, EE1 only) — The current variable’s settings.
A string containing the modified variable data to be saved.
Use this method to do something after the variable value has been saved to the database. You can access the current variable id with $this->var_id
and the settings with $this->settings
.
$var_data
(string) — The current variable data.
Use this method for displaying the variable value in your templates, using the {exp:low_variables:parse}
, {exp:low_variables:single}
and {exp:low_variables:pair}
tags. You can access the current variable id with $this->var_id
and the variable settings with $this->settings
(v2.2.1+). For Low Variables version 2.2.0 and lower, the settings will be available in the $tagparams
argument.
$tagparams
(array) — The tag parameters.$tagdata
(string) — The current tag data.$var_data
(string) — The current variable’s value.$var_settings
(array) — The current variable’s settings.
$var_data
(string) — The current variable’s value.$tagparams
(array) — The tag parameters.$tagdata
(string) — The current tag data.
A string containing the modified tagdata.
Use this method for additional processing before a variable is deleted.
$var_id
(int) — The ID of the variable about to be deleted.
NULL