diff --git a/e107_core/templates/header_default.php b/e107_core/templates/header_default.php index c7744cbae..99c4ec5e0 100644 --- a/e107_core/templates/header_default.php +++ b/e107_core/templates/header_default.php @@ -109,21 +109,28 @@ function render_title() define('e_PAGETITLE', $_PAGE_TITLE); } - $arr = []; - - if(!deftrue('e_FRONTPAGE')) + if($_FULL_TITLE = e107::getSingleton('eResponse')->getMetaTitle(true)) // override entire title. @see news_meta_title { - if(deftrue('e_PAGETITLE')) - { - $arr[] = e_PAGETITLE; - } - elseif(defined('PAGE_NAME')) - { - $arr[] = PAGE_NAME; - } + $arr = array($_FULL_TITLE); } + else + { + $arr = []; - $arr[] = SITENAME; + if(!deftrue('e_FRONTPAGE')) + { + if(deftrue('e_PAGETITLE')) + { + $arr[] = e_PAGETITLE; + } + elseif(defined('PAGE_NAME')) + { + $arr[] = PAGE_NAME; + } + } + + $arr[] = SITENAME; + } if($custom = e107::callMethod('theme', 'title', $arr)) { diff --git a/e107_handlers/application.php b/e107_handlers/application.php index 4f102bc86..e7bc7558b 100644 --- a/e107_handlers/application.php +++ b/e107_handlers/application.php @@ -4093,7 +4093,8 @@ class eResponse { protected $_body = array('default' => ''); protected $_title = array('default' => array()); - protected $_e_PAGETITLE = array(); + protected $_e_PAGETITLE = array(); // partial tag. + protected $_e_PAGETITLE_OVERRIDE = array(); // Full <title> tag protected $_META_DESCRIPTION = array(); protected $_META_KEYWORDS = array(); protected $_render_mod = array('default' => 'default'); @@ -4600,7 +4601,7 @@ class eResponse { $content = str_replace('&', '&', $content); - if($meta !== '_e_PAGETITLE') + if($meta !== '_e_PAGETITLE' && $meta !== '_e_PAGETITLE_OVERRIDE') { $content = htmlspecialchars((string) $content, ENT_QUOTES, 'UTF-8'); } @@ -4642,23 +4643,40 @@ class eResponse * @param string $title * @return eResponse */ - public function addMetaTitle($title, $reset=false) + public function addMetaTitle($title, $reset=false, $override=false) { if($reset) { - $this->_e_PAGETITLE = array(); + if($override) + { + $this->_e_PAGETITLE_OVERRIDE = array(); + } + else + { + $this->_e_PAGETITLE = array(); + } } $title = str_replace([''','''], "'", $title); + if($override) + { + return $this->addMetaData('e_PAGETITLE_OVERRIDE', $title); + } + return $this->addMetaData('e_PAGETITLE', $title); } /** * @return string */ - public function getMetaTitle() + public function getMetaTitle($override = false) { + if($override) + { + return $this->getMetaData('e_PAGETITLE_OVERRIDE', $this->_meta_title_separator); + } + return $this->getMetaData('e_PAGETITLE', $this->_meta_title_separator); } diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index a7c638816..8d76e5416 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -2825,14 +2825,15 @@ class e107 } /** - * Set the Page Title ie. <title>Whatever + * Set the Page Title ie. Whatever | SITENAME or Whatever * @param string $title + * @param string $override will remove any additional data from the tag. eg. | SITENAME etc. */ - public static function title($title) + public static function title($title, $override=false) { /** @var eResponse $response */ $response = self::getSingleton('eResponse'); - $response->addMetaTitle($title, true); + $response->addMetaTitle($title, true, $override); } /** diff --git a/e107_plugins/news/news.php b/e107_plugins/news/news.php index 20c3ababb..f76e7b114 100644 --- a/e107_plugins/news/news.php +++ b/e107_plugins/news/news.php @@ -662,7 +662,7 @@ class news_front if(!empty($news['news_meta_title'])) // override title with meta title. { - e107::title($news['news_meta_title']); + e107::title($news['news_meta_title'], true); } if($news['news_meta_description'] && !defined('META_DESCRIPTION'))