From: Roland Häder Date: Thu, 14 Jan 2010 20:09:03 +0000 (+0000) Subject: New filters introduced for page header, obsolete template removed: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9b8d0c1de007c1149af813c07773c3536c71ddd5;p=mailer.git New filters introduced for page header, obsolete template removed: - New filters 'pre_page_header' and 'post_page_header' introduced to let extensions add their own JavaScript inclusions. - The HTML template 'header.tpl' is now no longer needed --- diff --git a/.gitattributes b/.gitattributes index 00ddc0e1b9..8befaa27d5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1421,7 +1421,6 @@ templates/de/html/guest/guest_top10_empty5.tpl -text templates/de/html/guest/guest_top10_row_earner.tpl -text templates/de/html/guest/guest_top10_row_login.tpl -text templates/de/html/guest/guest_top10_row_refs.tpl -text -templates/de/html/header.tpl -text templates/de/html/impressum.tpl -text templates/de/html/index.tpl -text templates/de/html/index_forward.tpl -text diff --git a/inc/filter-functions.php b/inc/filter-functions.php index 046ea8ad25..82747fef79 100644 --- a/inc/filter-functions.php +++ b/inc/filter-functions.php @@ -114,6 +114,14 @@ ORDER BY registerFilter('init', 'UPDATE_LOGIN_DATA'); registerFilter('init', 'ACTIVATE_EXCHANGE'); + // Page headers - pre-filter (normally, you want to register here) + registerFilter('pre_page_header', 'LOAD_PAGE_HEADER'); + + // Page headers - post-filter (normally, you don't want to register here) + // ------------------- LAST FILTER FOR THIS CHAIN! ------------------------ + registerFilter('post_page_header', 'FINISH_PAGE_HEADER'); + // ------------------- LAST FILTER FOR THIS CHAIN! ------------------------ + // Login failures handler registerFilter('post_youhere_line', 'CALL_HANDLER_LOGIN_FAILTURES'); diff --git a/inc/filters.php b/inc/filters.php index 5fc55a5136..8636a3813b 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -933,5 +933,36 @@ function FILTER_DO_LOGIN_ADMIN ($data) { return $data; } +// Filter for loading page header, this should be ran first! +function FILTER_LOAD_PAGE_HEADER () { + // Determine the page title + $content['header_title'] = determinePageTitle(); + + // Output page header code + $GLOBALS['page_header'] = loadTemplate('page_header', true, $content); + + // Include meta data in 'guest' module + if (getModule() == 'index') { + // Load meta data template + $GLOBALS['page_header'] .= loadTemplate('metadata', true); + + // Add meta description to header + if ((isInstalled()) && (isAdminRegistered()) && (SQL_IS_LINK_UP())) { + // Add meta description not in admin and login module and when the script is installed + generateMetaDescriptionCode(); + } // END - if + } // END - if +} + +// Filter for adding style sheet, closing page header +function FILTER_FINISH_PAGE_HEADER () { + // Include stylesheet + loadIncludeOnce('inc/stylesheet.php'); + + // Closing HEAD tag + $GLOBALS['page_header'] .= ''; +} + // [EOF] ?> + diff --git a/inc/functions.php b/inc/functions.php index da1d2508a2..c1293681ce 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -3792,32 +3792,18 @@ function isSpider () { // Prepares the header for HTML output function loadHtmlHeader () { - // Determine the page title - $content['header_title'] = determinePageTitle(); + // Run two filters: + // 1.) pre_page_header (mainly loads the page_header template and includes + // meta description) + runFilterChain('pre_page_header'); - // Output page header code - $GLOBALS['page_header'] = loadTemplate('page_header', true, $content); - - // Include meta data in 'guest' module - if (getModule() == 'index') { - // Load meta data template - $GLOBALS['page_header'] .= loadTemplate('metadata', true); - - // Add meta description to header - if ((isInstalled()) && (isAdminRegistered()) && (SQL_IS_LINK_UP())) { - // Add meta description not in admin and login module and when the script is installed - generateMetaDescriptionCode(); - } // END - if - } // END - if + // Here can be something be added, but normally one of the two filters + // around this line should do the job for you. + // 2.) post_page_header (mainly to load stylesheet, extra JavaScripts and + // to close the head-tag) // Include more header data here - $GLOBALS['page_header'] .= loadTemplate('header', true); - - // Include stylesheet - loadIncludeOnce('inc/stylesheet.php'); - - // Closing HEAD tag - $GLOBALS['page_header'] .= ''; + runFilterChain('post_page_header'); } // Adds page header and footer to output array element diff --git a/templates/de/html/header.tpl b/templates/de/html/header.tpl deleted file mode 100644 index e69de29bb2..0000000000