smarty3 で、{include} タグに smarty テンプレートが含まれているかどうかを確認する方法はありますか? たとえば、そのようにできることはわかっています。
{include file="blahblah.tpl" included=1}
そして内 blahblah.tpl
{if $included==1}
yadda yadda yadda
{/if}
もっと簡単な方法があれば知りたいです。
テンプレートファイルを含める前に、template_exists()を使用して、テンプレートが存在するかどうかを確認できます。
if( !$smarty->template_exists($mid_template) ){
$mid_template = 'page_not_found.tpl';
} else {
$mid_template = 'blahblah.tpl';
}
$smarty->assign('content_template', $mid_template);