1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 22:27:34 +02:00

Issue #4783 Site name was still being appended to the <title> tag. Site name has now been removed when using news_meta_title.

This commit is contained in:
Cameron
2022-06-06 19:15:41 -07:00
parent 94bf1efda2
commit 08eb2a37d9
4 changed files with 47 additions and 21 deletions

View File

@@ -109,21 +109,28 @@ function render_title()
define('e_PAGETITLE', $_PAGE_TITLE); define('e_PAGETITLE', $_PAGE_TITLE);
} }
$arr = []; if($_FULL_TITLE = e107::getSingleton('eResponse')->getMetaTitle(true)) // override entire title. @see news_meta_title
if(!deftrue('e_FRONTPAGE'))
{ {
if(deftrue('e_PAGETITLE')) $arr = array($_FULL_TITLE);
{
$arr[] = e_PAGETITLE;
}
elseif(defined('PAGE_NAME'))
{
$arr[] = PAGE_NAME;
}
} }
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)) if($custom = e107::callMethod('theme', 'title', $arr))
{ {

View File

@@ -4093,7 +4093,8 @@ class eResponse
{ {
protected $_body = array('default' => ''); protected $_body = array('default' => '');
protected $_title = array('default' => array()); protected $_title = array('default' => array());
protected $_e_PAGETITLE = array(); protected $_e_PAGETITLE = array(); // partial <title> tag.
protected $_e_PAGETITLE_OVERRIDE = array(); // Full <title> tag
protected $_META_DESCRIPTION = array(); protected $_META_DESCRIPTION = array();
protected $_META_KEYWORDS = array(); protected $_META_KEYWORDS = array();
protected $_render_mod = array('default' => 'default'); protected $_render_mod = array('default' => 'default');
@@ -4600,7 +4601,7 @@ class eResponse
{ {
$content = str_replace('&amp;', '&', $content); $content = str_replace('&amp;', '&', $content);
if($meta !== '_e_PAGETITLE') if($meta !== '_e_PAGETITLE' && $meta !== '_e_PAGETITLE_OVERRIDE')
{ {
$content = htmlspecialchars((string) $content, ENT_QUOTES, 'UTF-8'); $content = htmlspecialchars((string) $content, ENT_QUOTES, 'UTF-8');
} }
@@ -4642,23 +4643,40 @@ class eResponse
* @param string $title * @param string $title
* @return eResponse * @return eResponse
*/ */
public function addMetaTitle($title, $reset=false) public function addMetaTitle($title, $reset=false, $override=false)
{ {
if($reset) if($reset)
{ {
$this->_e_PAGETITLE = array(); if($override)
{
$this->_e_PAGETITLE_OVERRIDE = array();
}
else
{
$this->_e_PAGETITLE = array();
}
} }
$title = str_replace(['&#39;','&#039;'], "'", $title); $title = str_replace(['&#39;','&#039;'], "'", $title);
if($override)
{
return $this->addMetaData('e_PAGETITLE_OVERRIDE', $title);
}
return $this->addMetaData('e_PAGETITLE', $title); return $this->addMetaData('e_PAGETITLE', $title);
} }
/** /**
* @return string * @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); return $this->getMetaData('e_PAGETITLE', $this->_meta_title_separator);
} }

View File

@@ -2825,14 +2825,15 @@ class e107
} }
/** /**
* Set the Page Title ie. <title>Whatever</title> * Set the Page Title ie. <title>Whatever | SITENAME</title> or <title>Whatever</title>
* @param string $title * @param string $title
* @param string $override will remove any additional data from the <title> tag. eg. | SITENAME etc.
*/ */
public static function title($title) public static function title($title, $override=false)
{ {
/** @var eResponse $response */ /** @var eResponse $response */
$response = self::getSingleton('eResponse'); $response = self::getSingleton('eResponse');
$response->addMetaTitle($title, true); $response->addMetaTitle($title, true, $override);
} }
/** /**

View File

@@ -662,7 +662,7 @@ class news_front
if(!empty($news['news_meta_title'])) // override title with meta title. 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')) if($news['news_meta_description'] && !defined('META_DESCRIPTION'))