Code: Select all
if (!$this->IsFileTemplateCached($template, '', '', $name)) {
// здесь выполняем подготовительный код
}
echo $this->ProcessTemplate($template, '', true, $name);
1. /lib/classes/class.module.inc.php
Code: Select all
function ProcessTemplate($tpl_name, $designation = '', $cache = false, $cacheid = '')
{
$this->LoadTemplateMethods();
// здесь принудительно отключается кэширование: $cache = false
return cms_module_ProcessTemplate($this, $tpl_name, $designation, $cache = false, $cacheid);
}
Code: Select all
function cms_module_IsFileTemplateCached(&$modinstance, $tpl_name, $designation = '', $timestamp = '', $cacheid = '')
{
$ok = (strpos($tpl_name, '..') === false);
if (!$ok) return;
global $gCms;
$smarty = &$gCms->GetSmarty();
$oldcache = $smarty->caching;
// Здесь принудительно отключается кэширование в любом случае
$smarty->caching = false;
// А дальше проверяется наличие кэша - непонятно зачем... Мне кажется, что имелось ввиду $smarty->caching = true;
$result = $smarty->is_cached('module_file_tpl:'.$modinstance->GetName().';'.$tpl_name, $cacheid, ($designation != ''?$designation:$modinstance->GetName()));
if ($result == true && $timestamp != '' && intval($smarty->_cache_info['timestamp']) < intval($timestamp))
{
$smarty->clear_cache('module_file_tpl:'.$modinstance->GetName().';'.$tpl_name, $cacheid, ($designation != ''?$designation:$modinstance->GetName()));
$result = false;
}
$smarty->caching = $oldcache;
return $result;
}
function cms_module_ProcessTemplate(&$modinstance, $tpl_name, $designation = '', $cache = false, $cacheid = '')
{
$ok = (strpos($tpl_name, '..') === false);
if (!$ok) return;
global $gCms;
$smarty = &$gCms->GetSmarty();
$oldcache = $smarty->caching;
// Здесь тоже самое, по моему должно быть: $smarty->caching = $cache;
$smarty->caching = false;
$result = $smarty->fetch('module_file_tpl:'.$modinstance->GetName().';'.$tpl_name, $cacheid, ($designation != ''?$designation:$modinstance->GetName()));
$smarty->caching = $oldcache;
return $result;
}