WHMCS - извлечение Smarty, вызывающее 500 внутреннюю ошибку сервера - PullRequest
0 голосов
/ 30 сентября 2018

Я пытаюсь переопределить шаблон smarty (smarty3) из ClientAreaPage хука WHMCS.Но когда я выбираю собственный шаблон, он продолжает загружаться и загружаться до тех пор, пока не закончится память, и выдает 500 внутренних ошибок сервера!Не могу понять это.

Вот мой код:

add_hook('ClientAreaPage', 1, function( $vars ) {
    global $smarty;

    //tried with "post" and "output" filter - without any luck.
    $smarty->registerFilter('pre','template_override_output_filter');
});

function template_override_output_filter($tpl_output, Smarty_Internal_Template $template) {
    global $smarty;

    $template_file_path = $template->_current_file;

    //getting filename
    $parts = explode('/', $template_file_path);
    $template_file_name = array_pop($parts);

    $custom_directory = 'custom';
    $new_file = ROOTDIR . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $custom_directory . DIRECTORY_SEPARATOR . $template_file_name;

    if (!file_exists($new_file)) {
        return $tpl_output;
    }

    $tpl_output = $smarty->fetch($new_file);

    return $tpl_output;
}

$new_file возвращает путь к файлу правильно.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...