Question

My ajax php located in maindirexample/actions is calling a tpl file one folder up in maindirexample/templates

fetch('../templates/popupMyItems.tpl'); 

However this throws an error

<br /> <b>Fatal error</b>: Uncaught exception 'SmartyException' with message 'Unable to load template file 'list-myItems.tpl' in '../templates/popupMyItems.tpl'

popupMyitems.tpl seems to be called ok, however list-myItems.tpl fails (this is included in 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}

Using

{include file="../templates/list-myItems.tpl"}

also fails :

'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

Any ideas?

Thanks

Was it helpful?

Solution

You need to include it from ../templates/ as well. Smarty does not search the "current folder" for inclusions, but rather the include_dir specified in settings. So you should do something like this:

{include file="../templates/list-myItems.tpl" category="{$category|replace:' ':''}" active="true"}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top