Frontend\Core\Engine\Theme::getPath PHP Method

getPath() public static method

If it does not exist in the theme it will return $file.
public static getPath ( string $file ) : string
$file string Path to the file.
return string Path to the (theme) file.
    public static function getPath($file)
    {
        // redefine
        $file = (string) $file;
        // theme name
        $theme = self::getTheme();
        // theme in use
        if (Model::get('fork.settings')->get('Core', 'theme', 'core') != 'core') {
            // theme not yet specified
            if (mb_strpos($file, 'src/Frontend/Themes/' . $theme) === false) {
                // add theme location
                $themeTemplate = str_replace(array('src/Frontend/'), array('src/Frontend/Themes/' . $theme . '/'), $file);
                // check if this template exists
                if (is_file(PATH_WWW . str_replace(PATH_WWW, '', $themeTemplate))) {
                    $file = $themeTemplate;
                }
            }
        }
        // check if the file exists
        if (!is_file(PATH_WWW . str_replace(PATH_WWW, '', $file))) {
            throw new Exception('The template (' . $file . ') does not exist.');
        }
        // return template path
        return $file;
    }

Usage Example

 /**
  * Execute the extra
  */
 public function execute()
 {
     parent::execute();
     $this->loadData();
     $widgetTemplatesPath = FRONTEND_MODULES_PATH . '/Pages/Layout/Widgets';
     // check if the given template exists
     try {
         $template = FrontendTheme::getPath($widgetTemplatesPath . '/' . $this->data['template']);
     } catch (FrontendException $e) {
         // template does not exist; assume subpages_default.tpl
         $template = FrontendTheme::getPath($widgetTemplatesPath . '/PreviousNextNavigation.tpl');
     }
     $this->loadTemplate($template);
     $this->parse();
 }
All Usage Examples Of Frontend\Core\Engine\Theme::getPath