[英]smarty fetch include on the fetched tpl page fails
位於maindirexample / actions的我的ajax php在maindirexample / templates中調用一個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 Foundation\Apache2.2\htdocs\ex\libs\sysplugins\smarty_internal_templatebase.php:127 Stack trace: #0 C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\ex\libs\sysplugins\smarty_internal_template.php(286): Smarty_Internal_TemplateBase->fetch(NULL, NULL, NULL, NULL, false, false, true) #1 C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\ex\main\actions\templates_c\07c3452c9173e47b89ab427877861e26b839928c.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 Foundation\Apache2.2\htdocs\ex\libs\sysplugins\smarty_internal_templatebase.php(180): content_5236279826e113_69075833(Object(Smarty_Internal_Template)) #3 C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\ex\main\actions in <b>C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\ex\libs\sysplugins\smarty_internal_templatebase.php</b> on line
有任何想法嗎?
謝謝
您還需要從../templates/中包含它。 Smarty不會在“當前文件夾”中搜索包含內容,而是搜索設置中指定的include_dir。 所以你應該做這樣的事情:
{include file="../templates/list-myItems.tpl" category="{$category|replace:' ':''}" active="true"}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.