From 1d45f1e4c42687a0ea99a9e7140b62ba2e082629 Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 22 Aug 2019 14:28:59 -0700 Subject: [PATCH] Fixes #3932 Added support for dynamic header/footer templates controlled by theme_shortcodes class. --- e107_core/templates/footer_default.php | 2 ++ e107_core/templates/header_default.php | 2 ++ e107_handlers/menumanager_class.php | 2 ++ e107_handlers/shortcode_handler.php | 10 ++++++---- e107_handlers/theme_handler.php | 13 +++++++++++++ 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/e107_core/templates/footer_default.php b/e107_core/templates/footer_default.php index 2f2f716a2..6f0e705e3 100644 --- a/e107_core/templates/footer_default.php +++ b/e107_core/templates/footer_default.php @@ -72,6 +72,8 @@ if (varset($e107_popup) != 1) $psc = array( '' => '', '{THEME}' => THEME_ABS, + '{---HEADER---}' => $tp->parseTemplate('{HEADER}',true), + '{---FOOTER---}' => $tp->parseTemplate('{FOOTER}',true) ); parseheader($FOOTER, $psc); diff --git a/e107_core/templates/header_default.php b/e107_core/templates/header_default.php index 29515c5cf..64d3835e8 100644 --- a/e107_core/templates/header_default.php +++ b/e107_core/templates/header_default.php @@ -804,6 +804,8 @@ if ($e107_popup != 1) { '{BODY_ONLOAD}' => $body_onload, '{LAYOUT_ID}' => 'layout-'.e107::getForm()->name2id(THEME_LAYOUT), '{---MODAL---}' => $LAYOUT['_modal_'], + '{---HEADER---}' => $tp->parseTemplate('{HEADER}',true), + '{---FOOTER---}' => $tp->parseTemplate('{FOOTER}',true), ); parseheader($HEADER, $psc); diff --git a/e107_handlers/menumanager_class.php b/e107_handlers/menumanager_class.php index 2a3a096e5..f57b32ecc 100644 --- a/e107_handlers/menumanager_class.php +++ b/e107_handlers/menumanager_class.php @@ -2186,6 +2186,8 @@ class e_menu_layout $layout = array(); + + foreach($head as $k=>$v) { $template = $head[$k]."\n{---}".$foot[$k]; diff --git a/e107_handlers/shortcode_handler.php b/e107_handlers/shortcode_handler.php index 9935b18ee..b24ae9566 100644 --- a/e107_handlers/shortcode_handler.php +++ b/e107_handlers/shortcode_handler.php @@ -527,14 +527,16 @@ class e_parse_shortcode * * @return e_parse_shortcode */ - public function loadThemeShortcodes() + public function loadThemeShortcodes($theme=null) { global $register_sc; - - if(file_exists(THEME."theme_shortcodes.php")) + + $themePath = ($theme === null) ? THEME : e_THEME.$theme.'/'; + + if(file_exists($themePath."theme_shortcodes.php")) { $classFunc = 'theme_shortcodes'; - $path = THEME."theme_shortcodes.php"; + $path = $themePath."theme_shortcodes.php"; include_once($path); $this->registerClassMethods($classFunc, $path, false); } diff --git a/e107_handlers/theme_handler.php b/e107_handlers/theme_handler.php index 5a6c437b7..61896b447 100644 --- a/e107_handlers/theme_handler.php +++ b/e107_handlers/theme_handler.php @@ -102,6 +102,19 @@ class e_theme list($LAYOUT['_header_'], $LAYOUT['_footer_']) = explode("{---LAYOUT---}", $tmp, 2); + $tp = e107::getParser(); + e107::getScParser()->loadThemeShortcodes($theme); + + if(strpos($LAYOUT['_header_'], '{---HEADER---}')!==false) + { + $LAYOUT['_header_'] = str_replace('{---HEADER---}', $tp->parseTemplate('{HEADER}', true), $LAYOUT['_header_']); + } + + if(strpos($LAYOUT['_footer_'], '{---FOOTER---}')!==false) + { + $LAYOUT['_footer_'] = str_replace('{---FOOTER---}', $tp->parseTemplate('{FOOTER}', true), $LAYOUT['_footer_']); + } + $LAYOUT[$key] = file_get_contents(e_THEME.$theme."/layouts/".$key."_layout.html"); return $LAYOUT;