Hello everyone, I change the "engine" i. Smarty 2 on Smarty 3, in the script settings (config.php) in PHP using Smarty 2 is:
require_once($config['basedir'].'/smarty/libs/Smarty.class.php'); require_once($config['basedir'].'/libraries/mysmarty.class.php'); ... STemplate::assign ... STemplate::setCompileDir ... STemplate::setTplDir ... In index.php (the main one in the root of the domain) is:
STemplate::display('header.tpl'); STemplate::display('index.tpl'); STemplate::display('footer.tpl'); Smarty.class.php is standard (all with comments), and in a special file (mysmarty.class.php) there is this:
<?php class STemplate { function STemplate() { global $Smarty; if (!isset($Smarty)) { $Smarty = new Smarty; } } function create() { global $Smarty; $Smarty = new Smarty(); $Smarty->compile_check = true; $Smarty->debugging = false; $Smarty->template_dir = dirname(__FILE__) . "/../../themes"; $Smarty->compile_dir = dirname(__FILE__) . "/../../temporary"; return true; } function setCompileDir($dir_name) { global $Smarty; if (!isset($Smarty)) { STemplate::create(); } $Smarty->compile_dir = $dir_name; } function setType($type) { global $Smarty; if (!isset($Smarty)) { STemplate::create(); } $Smarty->type = $type; } function assign($var, $value) { global $Smarty; if (!isset($Smarty)) { STemplate::create(); } $Smarty->assign($var, $value); } function setTplDir($dir_name = null) { global $Smarty; if (!isset($Smarty)) { STemplate::create(); } if (!$dir_name) { $Smarty->template_dir = dirname(__FILE__) . "/../../themes/default"; } else { $Smarty->template_dir = $dir_name; } } function setModule($module) { global $Smarty; if (!isset($Smarty)) { STemplate::create(); } $Smarty->theme = $module; $Smarty->type = "module"; } function setTheme($theme) { global $Smarty; if (!isset($Smarty)) { STemplate::create(); } $Smarty->template_dir = dirname(__FILE__) . "/../../themes/" . $theme; $Smarty->compile_dir = dirname(__FILE__) . "/../../temporary/" . $theme; $Smarty->theme = $theme; $Smarty->type = "theme"; } function getTplDir() { global $Smarty; if (!isset($Smarty)) { STemplate::create(); } return $Smarty->template_dir; } function display($filename) { global $Smarty; if (!isset($Smarty)) { STemplate::create(); } $Smarty->display($filename); } function fetch($filename) { global $Smarty; if (!isset($Smarty)) { STemplate::create(); } return $Smarty->fetch($filename); } function getVars() { global $Smarty; if (!isset($Smarty)) { STemplate::create(); } return $Smarty->get_template_vars(); } } ?> Calling functions in files comes with STemplate :: ...
The question is whether something needs to be changed in mysmarty.class.php when switching from Smarty 2 to Smarty 3 (except for files from the developer)? PS foreach in the project template file is running
STemplateis basically some sort of useless hat. In principle, this is similar to the implementation of a singleton on a global variable with the main functions of smarti. - teran pm