@@ -29,27 +29,43 @@ class Document
2929 protected $ minify_js = false ;
3030 protected $ minify_html = false ;
3131 protected static $ _fontawesome = false ;
32+ protected static $ _layout_paths = [];
3233
3334 public function __construct ()
3435 {
3536 $ params = Framework::getTemplate ()->getParams ();
3637 $ this ->minify_css = $ params ->get ('minify_css ' , false );
3738 $ this ->minify_js = $ params ->get ('minify_js ' , false );
3839 $ this ->minify_html = $ params ->get ('minify_html ' , false );
40+
41+
42+ $ template = Framework::getTemplate ();
43+ $ this ->addLayoutPath (JPATH_LIBRARIES . '/astroid/framework/frontend/ ' );
44+ $ this ->addLayoutPath (JPATH_SITE . '/templates/ ' . $ template ->template . '/html/frontend/ ' );
45+ }
46+
47+ public function addLayoutPath ($ path )
48+ {
49+ self ::$ _layout_paths [] = $ path ;
3950 }
4051
4152 public function include ($ section , $ data = [], $ return = false )
4253 {
43- $ template = Framework::getTemplate ();
4454 $ path = null ;
4555 $ name = str_replace ('. ' , '/ ' , $ section );
4656 if (Framework::isAdmin () && file_exists (JPATH_LIBRARIES . '/astroid/framework/layouts/ ' . $ name . '.php ' )) {
4757 $ path = JPATH_LIBRARIES . '/astroid/framework/layouts ' ;
48- } else if (file_exists (JPATH_SITE . '/templates/ ' . $ template ->template . '/html/frontend/ ' . $ name . '.php ' )) {
49- $ path = JPATH_SITE . '/templates/ ' . $ template ->template . '/html/frontend ' ;
50- } else if (file_exists (JPATH_LIBRARIES . '/astroid/framework/frontend/ ' . $ name . '.php ' )) {
51- $ path = JPATH_LIBRARIES . '/astroid/framework/frontend ' ;
5258 } else {
59+ foreach (self ::$ _layout_paths as $ layout_path ) {
60+ $ layout_path = substr ($ layout_path , -1 ) == '/ ' ? $ layout_path : $ layout_path . '/ ' ;
61+ if (file_exists ($ layout_path . $ name . '.php ' )) {
62+ $ path = $ layout_path ;
63+ break ;
64+ }
65+ }
66+ }
67+
68+ if ($ path === null ) {
5369 return '' ;
5470 }
5571
0 commit comments