Smarty - 捕获“无法加载模板”错误

i use automatic loading .tpl files by get parameter.

The parameter might be wrong and on next move it stops by error "Smarty: Unable to load template".

Can i catch this error and redirect page to some default template?

Thank you very much!

$seo = $params[0];
$smarty->display($seo . '.tpl');

Smarty has a function to check if a template exists.

From the documentation:

if( !$smarty->template_exists($mid_template) ){
    $mid_template = 'page_not_found.tpl';
}

You can for example use it like this:

if($smarty->template_exists($template)) {
    header("Location: error.html");
    exit();
}
$smarty->display($template);