1 Friendica Templating Documentation
2 ==================================
6 Friendica uses [Smarty 3](http://www.smarty.net/) as PHP templating engine.
7 The main templates are found in
11 theme authors may overwrite the default templates by putting a files with the same name into the
13 /view/themes/$themename/templates
17 Templates that are only used by addons shall be placed in the
19 /addon/$addonname/templates
23 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.
25 $tpl = Renderer::getMarkupTemplate('install_settings.tpl');
26 $o .= Renderer::replaceMacros($tpl, array( ... ));
28 the array consists of an association of an identifier and the value for that identifier, i.e.
30 '$title' => $install_title,
32 where the value may as well be an array by its own.
37 To guarantee a consistent look and feel for input forms, i.e. in the settings sections, there are templates for the basic form fields.
38 They are initialized with an array of data, depending on the tyle of the field.
40 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 addresses use something along the lines of:
42 '$adminmail' => array('adminmail', DI::l10n()->t('Site administrator email address'), $adminmail, DI::l10n()->t('Your account email address must match this in order to use the web admin panel.'), 'required', '', 'email'),
44 To evaluate the input value, you can then use the $_POST array, more precisely the $_POST['adminemail'] variable.
46 Listed below are the template file names, the general purpose of the template and their field parameters.
48 ### field_checkbox.tpl
51 If the checkbox is checked its value is **1**.
54 0. Name of the checkbox,
55 1. Label for the checkbox,
56 2. State checked? if true then the checkbox will be marked as checked,
57 3. Help text for the checkbox.
59 ### field_combobox.tpl
61 A combobox, combining a pull down selection and a textual input field.
64 0. Name of the combobox,
65 1. Label for the combobox,
66 2. Current value of the variable,
67 3. Help text for the combobox,
68 4. Array holding the possible values for the textual input,
69 5. Array holding the possible values for the pull down selection.
73 A customizable template to include a custom element in the form with the usual surroundings,
77 1. Label for the field,
79 3. Help text for the field.
83 A single line input field for any type of input.
87 1. Label for the input box,
88 2. Current value of the variable,
89 3. Help text for the input box,
90 4. Should be set to the translation of "Required" to mark this field as required,
91 5. if set to "autofocus" modern browser will put the cursor into this box once the page is loaded,
92 6. if set, it will be used for the input type, default is `text` (possible types: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#%3Cinput%3E_types).
94 ### field_intcheckbox.tpl
96 A checkbox (see above) but you can define the value of it.
99 0. Name of the checkbox,
100 1. Label for the checkbox,
101 2. State checked? if true then the checkbox will be marked as checked,
102 3. Value of the checkbox,
103 4. Help text for the checkbox.
107 An input box (see above) but prepared for special CSS styling for openID input.
110 0. Name of the field,
111 1. Label for the input box,
112 2. Current value of the variable,
113 3. Help text for the input field.
115 ### field_password.tpl
117 A single line input field (see above) for textual input.
118 The characters typed in will not be shown by the browser.
121 0. Name of the field,
122 1. Label for the field,
123 2. Value for the field, e.g. the old password,
124 3. Help text for the input field,
125 4. Should be set to the translation of "Required" to mark this field as required,
126 5. if set to "autofocus" modern browser will put the cursor automatically into this input field.
133 0. Name of the radio button,
134 1. Label for the radio button,
135 2. Current value of the variable,
136 3. Help text for the button,
137 4. if set, the radio button will be checked.
139 ### field_richtext.tpl
141 A multi-line input field for *rich* textual content.
144 0. Name of the input field,
145 1. Label for the input box,
146 2. Current text for the box,
147 3. Help text for the input box.
151 A drop down selection box.
154 0. Name of the field,
155 1. Label of the selection box,
156 2. Current selected value,
157 3. Help text for the selection box,
158 4. Array holding the possible values of the selection drop down.
160 ### field_select_raw.tpl
162 A drop down selection box (see above) but you have to prepare the values yourself.
165 0. Name of the field,
166 1. Label of the selection box,
167 2. Current selected value,
168 3. Help text for the selection box,
169 4. Possible values of the selection drop down.
171 ### field_textarea.tpl
173 A multi-line input field for (plain) textual content.
176 0. Name of the input field,
177 1. Label for the input box,
178 2. Current text for the box,
179 3. Help text for the input box,
180 4. Should be set to the translation of "Required" to mark this field as required.