23. 2 Установка Smarty
В книге написано про актуальную версию 2.6.26.
На 02.12.2020 актуальной является версия 3.1.35.
Сочетание этой версии Smarty и PHP7 заставляет внести изменения в код дальнейших глав:
23.3
Здесь автор приводит пример:
PHP:
скопировать код в буфер обмена
define('SMARTY_DIR', 'libs/'); require([b]SMARTYDIR[/b] . 'Smarty.class.php'); class MySmarty extends Smarty { function MySmarty () { [b]$this->Smarty();[/b] $this->template_dir = 'templates/'; $this->compile_dir = 'templates_c/'; $this->config_dir = 'config/'; $this->cache_dir = 'cache/'; $this->caching = true; } }
Однако данный пример не работает, ругается на ошибку в libs/sysplugins/smarty_internal_ data.php on line 290.
Чтобы обойти эту ошибку нужно исправить код на:
PHP:
скопировать код в буфер обмена
define('SMARTY_DIR', 'libs/'); require([b]SMARTY_DIR[/b] . 'Smarty.class.php'); class MySmarty extends Smarty{ function MySmarty () { [b]parent::__construct(); // $this->Smarty();[/b] $this->template_dir = 'templates/'; $this->compile_dir = 'templates_c/'; $this->config_dir = 'configs/'; $this->cache_dir = 'cache/'; $this->caching = true; } }
(Отредактировано автором: 04 Декабря, 2020 - 15:02:58)
|