diff --git a/contrib/smarty/plugins/function.filePath.php b/contrib/smarty/plugins/function.filePath.php
index 26c847b3df07713b15126a30b4fdf834a4e9975b..d212791f97450381d81c69f5d106f3d2eb22623d 100644
--- a/contrib/smarty/plugins/function.filePath.php
+++ b/contrib/smarty/plugins/function.filePath.php
@@ -16,14 +16,18 @@ function smarty_function_filePath($params, &$smarty)
   if (file_exists("themes/$theme/$filename")) {
     return "themes/$theme/$filename";
   }
-  if (file_exists($smarty->template_dir."/themes/$theme/$filename")) {
-    return $smarty->template_dir."/themes/$theme/$filename";
+  $dir = $smarty->template_dir;
+  if (is_array($dir)) {
+    $dir = $dir[0];
+  }
+  if (file_exists("$dir/themes/$theme/$filename")) {
+    return "$dir/themes/$theme/$filename";
   }
   if (file_exists("themes/default/$filename")) {
     return "themes/default/$filename";
   }
-  if (file_exists($smarty->template_dir."/themes/default/$filename")) {
-    return $smarty->template_dir."/themes/default/$filename";
+  if (file_exists("$dir/themes/default/$filename")) {
+    return "$dir/themes/default/$filename";
   }
   return $filename;
 }