2015-01-18 15:15:37 +00:00
Friendica Templating Documentation
==================================
* [Home ](help )
2017-09-24 08:52:14 +00:00
Friendica uses [Smarty 3 ](http://www.smarty.net/ ) as PHP templating engine.
The main templates are found in
2015-01-18 15:15:37 +00:00
/view/templates
theme authors may overwrite the default templates by putting a files with the same name into the
/view/themes/$themename/templates
directory.
Templates that are only used by addons shall be placed in the
/addon/$addonname/templates
directory.
2018-10-31 14:35:50 +00:00
To render a template use the function *getMarkupTemplate* to load the template and *replaceMacros* to replace the macros/variables in the just loaded template file.
2015-01-18 15:15:37 +00:00
2018-10-31 14:44:06 +00:00
$tpl = Renderer::getMarkupTemplate('install_settings.tpl');
2018-10-31 14:35:50 +00:00
$o .= Renderer::replaceMacros($tpl, array( ... ));
2015-01-18 15:15:37 +00:00
the array consists of an association of an identifier and the value for that identifier, i.e.
'$title' => $install_title,
where the value may as well be an array by its own.
Form Templates
--------------
2017-09-24 08:52:14 +00:00
To guarantee a consistent look and feel for input forms, i.e. in the settings sections, there are templates for the basic form fields.
They are initialized with an array of data, depending on the tyle of the field.
2015-01-18 15:15:37 +00:00
2017-09-24 08:52:14 +00:00
All of these take an array holding the values, e.g. for a one line text input field, which is required and should be used to type email addesses use something along the lines of:
2015-01-18 15:15:37 +00:00
2018-01-21 16:38:01 +00:00
'$adminmail' => array('adminmail', L10n::t('Site administrator email address'), $adminmail, L10n::t('Your account email address must match this in order to use the web admin panel.'), 'required', '', 'email'),
2015-01-18 15:15:37 +00:00
To evaluate the input value, you can then use the $_POST array, more precisely the $_POST['adminemail'] variable.
Listed below are the template file names, the general purpose of the template and their field parameters.
### field_checkbox.tpl
2017-09-24 08:52:14 +00:00
A checkbox.
If the checkbox is checked its value is **1** .
Field parameter:
2015-01-18 15:15:37 +00:00
0. Name of the checkbox,
1. Label for the checkbox,
2. State checked? if true then the checkbox will be marked as checked,
3. Help text for the checkbox.
### field_combobox.tpl
2017-09-24 08:52:14 +00:00
A combobox, combining a pull down selection and a textual input field.
Field parameter:
2015-01-18 15:15:37 +00:00
0. Name of the combobox,
1. Label for the combobox,
2. Current value of the variable,
3. Help text for the combobox,
4. Array holding the possible values for the textual input,
5. Array holding the possible values for the pull down selection.
### field_custom.tpl
2017-09-24 08:52:14 +00:00
A customizeable template to include a custom element in the form with the usual surroundings,
Field parameter:
2015-01-18 15:15:37 +00:00
0. Name of the field,
1. Label for the field,
2. the field,
3. Help text for the field.
### field_input.tpl
2019-12-05 20:42:33 +00:00
A single line input field for any type of input.
2017-09-24 08:52:14 +00:00
Field parameter:
2015-01-18 15:15:37 +00:00
0. Name of the field,
1. Label for the input box,
2. Current value of the variable,
3. Help text for the input box,
4. if set to "required" modern browser will check that this input box is filled when submitting the form,
5. if set to "autofocus" modern browser will put the cursur into this box once the page is loaded,
2019-12-05 20:42:33 +00:00
6. if set, it will be used for the input type, default is `text` (possible types: https://www.w3schools.com/html/html_form_input_types.asp).
2015-01-18 15:15:37 +00:00
### field_intcheckbox.tpl
2017-09-24 08:52:14 +00:00
A checkbox (see above) but you can define the value of it.
Field parameter:
2015-01-18 15:15:37 +00:00
0. Name of the checkbox,
1. Label for the checkbox,
2. State checked? if true then the checkbox will be marked as checked,
3. Value of the checkbox,
4. Help text for the checkbox.
### field_openid.tpl
2017-09-24 08:52:14 +00:00
An input box (see above) but prepared for special CSS styling for openID input.
Field parameter:
2015-01-18 15:15:37 +00:00
0. Name of the field,
1. Label for the input box,
2. Current value of the variable,
3. Help text for the input field.
### field_password.tpl
2017-09-24 08:52:14 +00:00
A single line input field (see above) for textual input.
The characters typed in will not be shown by the browser.
Field parameter:
2015-01-18 15:15:37 +00:00
0. Name of the field,
1. Label for the field,
2. Value for the field, e.g. the old password,
3. Help text for the input field,
4. if set to "required" modern browser will check that this field is filled out,
5. if set to "autofocus" modern browser will put the cursor automatically into this input field.
### field_radio.tpl
2017-09-24 08:52:14 +00:00
A radio button.
Field parameter:
2015-01-18 15:15:37 +00:00
0. Name of the radio button,
1. Label for the radio button,
2. Current value of the variable,
3. Help text for the button,
4. if set, the radio button will be checked.
### field_richtext.tpl
2017-09-24 08:52:14 +00:00
A multi-line input field for *rich* textual content.
Field parameter:
2015-01-18 15:15:37 +00:00
0. Name of the input field,
1. Label for the input box,
2. Current text for the box,
3. Help text for the input box.
### field_select.tpl
2017-09-24 08:52:14 +00:00
A drop down selection box.
Field parameter:
2015-01-18 15:15:37 +00:00
0. Name of the field,
1. Label of the selection box,
2. Current selected value,
3. Help text for the selection box,
4. Array holding the possible values of the selection drop down.
### field_select_raw.tpl
2017-09-24 08:52:14 +00:00
A drop down selection box (see above) but you have to prepare the values yourself.
Field parameter:
2015-01-18 15:15:37 +00:00
0. Name of the field,
1. Label of the selection box,
2. Current selected value,
3. Help text for the selection box,
4. Possible values of the selection drop down.
### field_textarea.tpl
2017-09-24 08:52:14 +00:00
A multi-line input field for (plain) textual content.
Field parameter:
2015-01-18 15:15:37 +00:00
0. Name of the input field,
1. Label for the input box,
2. Current text for the box,
3. Help text for the input box.
2019-10-02 05:33:30 +00:00
4. if set to "required" modern browser will check that this input box is filled when submitting the form,
2015-01-18 15:15:37 +00:00
### field_yesno.tpl
2017-09-24 08:52:14 +00:00
A button that has two states *yes* or *no* .
Field parameter:
2015-01-18 15:15:37 +00:00
0. Name of the input field,
1. Label for the button,
2. Current value,
3. Help text for the button
4. if set to an array of two values, these two will be used, otherwise "off" and "on".