Документация InstantCMS

для администраторов и разработчиков

Инструменты пользователя

Инструменты сайта


Using Helper Functions

The engine has a file containg a set of functions that make the «life» of layout designers and people working with InstantCMS templates easier and make the work with templates convenient. The functions in this file, as a rule, return a certain string containing HTML code. For example, the html_link function types the <a> HTML tag with the parameters passed to the function making the attributes safe from XSS.

A file with default helper functions

The file where all these functions are defined is located at /system/libs/template.helper.php. It is linked whenever a similar custom file is not specified for the template.

Creating a custom file with helper functions

If, in your template, you want to edit the data returned by these functions, for example, to force add classes to the tags or change the layout of relevant blocks, you should:

  1. Copy the /system/libs/template.helper.php file into /templates/YOUR_TEMPLATE/assets/helper.php, i.e. copy the default file into /templates/YOUR_TEMPLATE/assets/ and rename it into helper.php;
  2. Edit at your discretion but leave the main logic of the functions unchanged.

It is important to understand that ALL functions initially available in /system/libs/template.helper.php should be defined in the /templates/YOUR_TEMPLATE/assets/helper.php file, even if you edit only one function. However, you can certainly add custom helper functions and use them in your template.

Go to helper function description

Back to Section Contents

en/dev/templates/helpers.txt · Последнее изменение: 20.03.2017 15:13 — murlysja