0

maindirexample/actions にある私の ajax php は、maindirexample/templates の 1 フォルダー上の 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 は正常に呼び出されたようですが、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-&gt;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-&gt;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

何か案は?

ありがとう

4

1 に答える 1

2

../templates/ からも含める必要があります。Smarty は「現在のフォルダー」でインクルージョンを検索するのではなく、設定で指定された include_dir を検索します。したがって、次のようにする必要があります。

{include file="../templates/list-myItems.tpl" category="{$category|replace:' ':''}" active="true"}
于 2013-09-16T06:42:04.380 に答える