Syntax Smarty+;Prestashop:包含模板(如果存在)
我有以下代码,如果模板存在,我希望包含一个模板,否则会退回到直接输出内容Syntax Smarty+;Prestashop:包含模板(如果存在),syntax,smarty,prestashop,Syntax,Smarty,Prestashop,我有以下代码,如果模板存在,我希望包含一个模板,否则会退回到直接输出内容 {if $smarty->template_exists("$tpl_dir./cms.tpl")} {include file="$tpl_dir/$cms->link_rewrite.tpl"} { else } {$cms->content} { /if } 据我所知,我的语法是正确的,但我可能是错误的,因为我是新手。知道我做错了什么吗(我想可能是连接)?看起来像是连接问题。使用“反勾
{if $smarty->template_exists("$tpl_dir./cms.tpl")}
{include file="$tpl_dir/$cms->link_rewrite.tpl"}
{ else }
{$cms->content}
{ /if }
据我所知,我的语法是正确的,但我可能是错误的,因为我是新手。知道我做错了什么吗(我想可能是连接)?看起来像是连接问题。使用“反勾号”评估Smarty变量:
$smarty->template_exists("`$tpl_dir`/cms.tpl")
有关详细信息,请参见如果文件位于同一文件夹中,请尝试以下操作:
{assign var="file" value="`$smarty.current_dir`/file_name.tpl"}
{if $file|file_exists}
{include file=$file}
{/if}