SettingsDisplay class

FieldFrame comes with a class, Fieldframe_SettingsDisplay, that provides several convenience functions which you can use when displaying site settings and field settings.

Example usage

Here’s an example of using the SettingsDisplay class, based on FF Checkbox Group:

function display_site_settings()
{
	// Initialize a new instance of SettingsDisplay
	$SD = new Fieldframe_SettingsDisplay();
 
	// Open the settings block
	$r = $SD->block('Checkbox Group Settings');
 
	// Define the initial textarea value
	$value = isset($this->site_settings['option_tmpl'])
	  ?  $this->site_settings['option_tmpl']
	  :  '';
 
	// Define the textarea attributes
	$attr = array('rows' => '2');
 
	// Add the Default Option Template setting
	$r .= $SD->row(array(
	                 $SD->label('Default Option Template'),
	                 $SD->textarea('option_tmpl', $value, $attr)
	               ));
 
	// Close the settings block
	$r .= $SD->block_c();
 
	// Return the settings block
	return $r;
}

Functions Reference

All of the SettingsDisplay functions are listed here. They each return a snippet of HTML.

block

Creates the opening HTML for a new settings table. Used in conjunction with block_c().

Arguments
  • $title_line (string, optional) — The title of the settings block. Can be either a language line’s key or a normal text string
  • $num_cols (integer, optional) — The number of columns your settings block will have (2 by default)

block_c

Creates the closing HTML for a settings table. Used in conjunction with block().

row

Creates a new settings table row.

Arguments
  • $col_data (array) — An array of the individual columns’ inner-HTML snippets
  • $row_class (string, optional) — Class name to be added to each <td> element
  • $attr (array, optional) — name/value pairs of attributes to be added to the <tr> element

heading_row

Creates a settings table heading row.

Arguments
  • $col_data_(array)_ – An array of the individual column headers’ inner-HTML snippets

info_row

Creates a settings table info row.

Arguments
  • $info_line (string) — The info line. Can be either a language line’s key or a normal text string

label

Creates a settings label

Arguments
  • $label_line (string) — The label line. Can be either a language line’s key or a normal text string
  • $subtext_line (string, optional) — The subtext line. Can be either a language line’s key or a normal text string

text

Creates a textfield.

Arguments
  • $name (string) — The name of the textfield
  • $value (string) — The initial value of the textfield
  • $attr (array, optional) — The attributes of the textfield. Can include any of these optional key/value pairs:
    • size
    • maxlength
    • style — class name
    • width
    • extras — addional HTML attributes
    • convert (bool) — determines whether $value has its entities converted to ASCII text (FALSE by default)

textarea

Creates a textarea.

Arguments
  • $name (string) — The name of the textarea
  • $value (string) — The initial value of the textarea
  • $attr (array, optional) — The attributes of the textarea. Can include any of these optional key/value pairs:
    • rows
    • style — class name
    • width
    • extras — addional HTML attributes
    • convert (bool) — determines whether $value has its entities converted to ASCII text (FALSE by default)

select

Creates a select input.

Arguments
  • $name (string) — The name of the select input
  • $value (string) — The value of the initially-selected option
  • $options (array) — Value/name pairs for each of the options
  • $attr (array, optional) — The attributes of the select input. Can include any of these optional key/value pairs:
    • width

multiselect

Creates a multi-select input.

Arguments
  • $name (string) — The name of the multi-select input
  • $values (array) — The values of the initially-selected options
  • $options (array) — Value/name pairs for each of the options
  • $attr (array, optional) — The attributes of the multi-select input. Can include any of these optional key/value pairs:
    • size — number of visible rows
    • width

radio_group

Creates a radio group

Arguments
  • $name (string) — The name of the radio group
  • $value (string) — The value of the initially-selected option
  • $options (array) — Value/name pairs for each of the options
  • $attr (array, optional) — The attributes of the radio group. Can include any of these optional key/value pairs:
    • extras — addional HTML attributes