在smarty3中,有没有办法通过{include}标签找出是否包含了聪明的模板?我知道我可以这样做,例如:
{include file="blahblah.tpl" included=1}在blahblah.tpl内部
{if $included==1}
yadda yadda yadda
{/if}我只想知道有没有更简单的方法。
发布于 2012-10-13 13:29:40
在包含模板文件之前,您可以使用检查模板是否存在
if( !$smarty->template_exists($mid_template) ){
$mid_template = 'page_not_found.tpl';
} else {
$mid_template = 'blahblah.tpl';
}
$smarty->assign('content_template', $mid_template);https://stackoverflow.com/questions/12870177
复制相似问题