How to check if a file exists in Smarty 2

How to check if a file exists in Smarty 2? I mean something like this:

{assign var="module_js" value="/js/modules/{$module}.js"} {if file_exists($module_js)} <script type="text/javascript" src="{$module_js}"></script> {/if} 
+4
source share
1 answer

In fact, this has nothing to do with the Smarty version. But the way you assign a variable is wrong. Try as follows:

 {assign var="module_js" value="js/`$module`.js"} {if file_exists($module_js)} <script type="text/javascript" src="{$module_js}"></script> {/if} 
+5
source

Source: https://habr.com/ru/post/1447543/


All Articles