我的 ajax php 位于 maindirexample/actions 中调用一个文件夹的 tpl 文件
fetch('../templates/popupMyItems.tpl');
但是,这会引发错误
<br /> <b>Fatal error</b>: Uncaught exception 'SmartyException' with message 'Unable to load template file 'list-myItems.tpl' in '../templates/popupMyItems.tpl'
popupMyitems.tpl 似乎被称为 ok,但是 list-myItems.tpl 失败(这包含在 popupMyitems.tpl 中)。
{foreach
from=$uniquecategories item=category name=cat}
{if $smarty.foreach.cat.first} {include file="list-myItems.tpl"
category="{$category|replace:' ':''}" active="true"}
{else} {include
file="list-myItems.tpl" category="{$category|replace:' ':''}"
active="false"} {/if}
{/foreach}
用
{include file="../templates/list-myItems.tpl"}
也失败了:
'SmartyException' with message 'Unable to load template file 'list-myItems.tpl' in '../templates/popupMyItems.tpl'' in C:Program Files (x86)Apache Software FoundationApache2.2htdocsexlibssyspluginssmarty_internal_templatebase.php:127 Stack trace: #0 C:Program Files (x86)Apache Software FoundationApache2.2htdocsexlibssyspluginssmarty_internal_template.php(286): Smarty_Internal_TemplateBase->fetch(NULL, NULL, NULL, NULL, false, false, true) #1 C:Program Files (x86)Apache Software FoundationApache2.2htdocsexmainactionstemplates_c 7c3452c9173e47b89ab427877861e26b839928c.file.popupMyItems.tpl.php(52): Smarty_Internal_Template->getSubTemplate('list-myItems.tp...', NULL, NULL, NULL, NULL, Array, 0) #2 C:Program Files (x86)Apache Software FoundationApache2.2htdocsexlibssyspluginssmarty_internal_templatebase.php(180): content_5236279826e113_69075833(Object(Smarty_Internal_Template)) #3 C:Program Files (x86)Apache Software FoundationApache2.2htdocsexmainactions in <b>C:Program Files (x86)Apache Software FoundationApache2.2htdocsexlibssyspluginssmarty_internal_templatebase.php</b> on line
有什么想法吗?
谢谢
您需要从 ../模板/以及。Smarty不会在"当前文件夹"中搜索包含物,而是在设置中指定的include_dir。所以你应该做这样的事情:
{include file="../templates/list-myItems.tpl" category="{$category|replace:' ':''}" active="true"}