📜 ⬆️ ⬇️

Smarty - an easy way to understand the structure of other people's templates

Often it is necessary to understand some samopisny CMS which is arranged in a completely non-obvious way for you. Sometimes a lot of time is spent on understanding which template a particular piece of text is taken from. To understand the templates will help prefilter Smarty, prefilter is a function that is called before compiling each template.

//
function smarty_marktpl($tpl_source, &$smarty) {
$tpl_path = $smarty->template_dir.$smarty->_current_file;
return "<!-- [$tpl_path] -->".$tpl_source."<!-- /[$tpl_path] -->";
}
//
$smarty->register_prefilter('smarty_marktpl');

Now it remains only to look at the code of the generated page and immediately it becomes clear where it came from.

')

Source: https://habr.com/ru/post/94754/


All Articles