Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
en:start:template_features [2016/07/07 17:06] admin [2. Relation fields] |
en:start:template_features [2016/07/07 17:07] admin [4. Вставка пользовательских функций в шаблон обычных полей] |
||
---|---|---|---|
Line 54: | Line 54: | ||
Please read the following sections only, if you have some basic development skills, because they make use of the custom functions. (Green textfield)</WRAP> | Please read the following sections only, if you have some basic development skills, because they make use of the custom functions. (Green textfield)</WRAP> | ||
- | ====== 4. Вставка пользовательских функций в шаблон обычных полей ====== | + | ====== 4. Insert of custom functions inside default template fields ====== |
- | Вы можете использовать функции PHP даже в простых текстовых полях (синяя иконка). | + | A big improvement was the feature to insert a custom expression in every default textfield. (blue icon) This makes it possible to generate very complex values by the the usage of lots of php functions, without the limitations to the functions (green) textfields. |
- | Вам лишь нужно вставить следующее: | + | You only need to insert the following: |
${ ... custom function ... return "result"; }}> | ${ ... custom function ... return "result"; }}> | ||
| | ||
- | Оператор return является обязательным условием, потому что полный блок (от “${” до “}}>” ) будет заменен тем значением, которое возвращается с его помощью. Например, это позволяет вставлять округленные общие суммы: | + | Instead of ${ … }}> you also could use <?php … ?>, because the used script language is similar to PHP. **But these default PHP tags do not work within the HTML Editor, which the module use to create an E-Mail.** |
+ | |||
+ | The return statement is imperative, because the complete block (from “${” to “}}>” ) will be replaced the the return value. This allows for example the insert of a rounded total sum of an invoice by: | ||
${ return round($hdnGrandTotal, 2); }}> | ${ return round($hdnGrandTotal, 2); }}> | ||
| | ||
- | Можно вычислять выражения на основе дат из полей Записи: | + | Also this feature allows the calculation of dates from fields by: |
${ $date = strtotime($fieldname); $new_date = strtotime($date, "+1 day"); return date("Y-m-D", $new_date); }}> | ${ $date = strtotime($fieldname); $new_date = strtotime($date, "+1 day"); return date("Y-m-D", $new_date); }}> | ||
| | ||
- | //Пожалуйста, обратите внимание, внутри пользовательских функций вы должны использовать ссылки на поля из связанных модулей в стиле PHP %%($field->module->field)%%// | + | //Please note, you have to use the related variable structure of custom functions ($field→module→field) and not the Template structure of variables. ($field (module) field) The Variable chooser do not know this and you need to change the format for yourself. |
- | Остальные примеры я упомяну в отдельной статье о [[ru:start:custom_functions|Пользовательских Функциях]] | + | Other examples I will mention on a separate [[en:start:custom_functions|custom function]] page. |
====== 5. Использование локальных переменных (Только зеленые текстовые поля и пользовательские функции) ====== | ====== 5. Использование локальных переменных (Только зеленые текстовые поля и пользовательские функции) ====== |