- $a = get_app();
- $template_file = get_template_file($a, SMARTY3_TEMPLATE_FOLDER . '/' . $file, $root);
- $template = new FriendicaSmarty();
- $template->filename = $template_file;
+ // Make sure $root ends with a slash /
+ if ($subDir !== '' && substr($subDir, -1, 1) !== '/') {
+ $subDir = $subDir . '/';
+ }
+
+ $root = DI::basePath() . '/' . $subDir;
+
+ $filename = $this->smarty::SMARTY3_TEMPLATE_FOLDER . '/' . $file;
+
+ if (file_exists("{$root}view/theme/$this->theme/$filename")) {
+ $template_file = "{$root}view/theme/$this->theme/$filename";
+ } elseif (!empty($this->theme_info['extends']) && file_exists(sprintf('%sview/theme/%s}/%s', $root, $this->theme_info['extends'], $filename))) {
+ $template_file = sprintf('%sview/theme/%s}/%s', $root, $this->theme_info['extends'], $filename);
+ } elseif (file_exists("{$root}/$filename")) {
+ $template_file = "{$root}/$filename";
+ } else {
+ $template_file = "{$root}view/$filename";
+ }
+
+ $this->smarty->filename = $template_file;