Php smarty3检测模板是否被{include}包含

Php smarty3检测模板是否被{include}包含,php,smarty,smarty3,Php,Smarty,Smarty3,在smarty3中,是否有办法确定我的{include}标记中是否包含smarty模板? 我知道我可以这样做,例如: {include file="blahblah.tpl" included=1} 在blahblah.tpl内部 {if $included==1} yadda yadda yadda {/if} 我只是想知道是否有更简单的方法。在包含模板文件之前,您可以通过查看模板是否存在 if( !$smarty->template_exists($mid_template)

在smarty3中,是否有办法确定我的{include}标记中是否包含smarty模板? 我知道我可以这样做,例如:

{include file="blahblah.tpl" included=1}
在blahblah.tpl内部

{if $included==1}
  yadda yadda yadda 
{/if}

我只是想知道是否有更简单的方法。

在包含模板文件之前,您可以通过查看模板是否存在

if( !$smarty->template_exists($mid_template) ){
    $mid_template = 'page_not_found.tpl';
} else {
    $mid_template = 'blahblah.tpl';
}
$smarty->assign('content_template', $mid_template);

谢谢,但那不是我想要的。我想知道是否有可能找到模板是如何被调用的。就像在您的示例中,通过smarty对象,或者像在我的示例中一样,通过{include}smarty标记。