For work with site templates in the file includes/template.php is defined class
Template. The module object of this class is available through a variable
$this->diafan->_tpl
. In the module template class is accessible via
variable $this
.
string get (string $name, string $module, mixed $result, [string $template = '']) – Подключает шаблон.
Example:
// connect template of ads block if there is template
// modules/ab/views/ab.view.show_block_$attributes["template"].php
// otherwise connect the template modules/ab/views/ab.view.show_block.php
echo $this->diafan->_tpl->get('show_block', 'ab', $result, $attributes["template"]);
void js ([string $name = ''], [string $module = '']) – Подключает JS-файл.
Example:
// includes/controller.php
// connect JS-files common to the entire module
$this->diafan->_tpl->js();
void css ([string $name = ''], [string $module = '']) – Подключает CSS-файл.
string htmleditor (string $text) – Заменяет шаблонные теги, ссылки в тексте.
Example:
// output dynamic block by template tag
// in the file modules/news/views/news.view.id.php
echo $this->htmleditor('<insert name="show_dynamic" module="site" id="1">');
// treat news text, editable through a WYSIWYG editor
// in the file modules/news/news.model.php
$row["text"] = $this->diafan->_tpl->htmleditor($row["text"]);