mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 03:32:00 +09:00
Fix #491 no display of canonical URL on some pages
This commit is contained in:
parent
9fe37502b8
commit
3fbf94f630
3 changed files with 18 additions and 10 deletions
|
|
@ -98,6 +98,12 @@ class Context
|
|||
*/
|
||||
public $opengraph_metadata = array();
|
||||
|
||||
/**
|
||||
* Canonical URL
|
||||
* @var string
|
||||
*/
|
||||
public $canonical_url = '';
|
||||
|
||||
/**
|
||||
* path of Xpress Engine
|
||||
* @var string
|
||||
|
|
@ -2804,7 +2810,7 @@ class Context
|
|||
*/
|
||||
public static function setCanonicalURL($url)
|
||||
{
|
||||
self::addHtmlHeader(sprintf('<link rel="canonical" href="%s" />', escape($url)));
|
||||
self::$_instance->canonical_url = escape($url);
|
||||
}
|
||||
}
|
||||
/* End of file Context.class.php */
|
||||
|
|
|
|||
|
|
@ -415,33 +415,34 @@ class HTMLDisplayHandler
|
|||
if ($page_type === 'article' && config('seo.og_extract_description'))
|
||||
{
|
||||
$description = trim(utf8_normalize_spaces($oDocument->getContentText(200)));
|
||||
Context::addOpenGraphData('og:description', $description);
|
||||
Context::addMetaTag('description', $description);
|
||||
}
|
||||
else
|
||||
{
|
||||
Context::addOpenGraphData('og:description', Context::getMetaTag('description'));
|
||||
$description = Context::getMetaTag('description');
|
||||
}
|
||||
Context::addOpenGraphData('og:description', $description);
|
||||
Context::addMetaTag('description', $description);
|
||||
|
||||
// Add metadata about this page.
|
||||
Context::addOpenGraphData('og:type', $page_type);
|
||||
if ($page_type === 'article')
|
||||
{
|
||||
$document_canonical_url = getFullUrl('', 'mid', $current_module_info->mid, 'document_srl', $document_srl);
|
||||
Context::addOpenGraphData('og:url', $document_canonical_url);
|
||||
$canonical_url = getFullUrl('', 'mid', $current_module_info->mid, 'document_srl', $document_srl);
|
||||
}
|
||||
elseif (($page = Context::get('page')) > 1)
|
||||
{
|
||||
Context::addOpenGraphData('og:url', getFullUrl('', 'mid', $current_module_info->mid, 'page', $page));
|
||||
$canonical_url = getFullUrl('', 'mid', $current_module_info->mid, 'page', $page);
|
||||
}
|
||||
elseif ($current_module_info->module_srl == $site_module_info->module_srl)
|
||||
{
|
||||
Context::addOpenGraphData('og:url', Rhymix\Framework\URL::getCurrentDomainURL(\RX_BASEURL));
|
||||
$canonical_url = getFullUrl('');
|
||||
}
|
||||
else
|
||||
{
|
||||
Context::addOpenGraphData('og:url', getFullUrl('', 'mid', $current_module_info->mid));
|
||||
$canonical_url = getFullUrl('', 'mid', $current_module_info->mid);
|
||||
}
|
||||
Context::addOpenGraphData('og:url', $canonical_url);
|
||||
Context::setCanonicalURL($canonical_url);
|
||||
|
||||
// Add metadata about the locale.
|
||||
$lang_type = Context::getLangType();
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@
|
|||
<link rel="alternate" type="application/atom+xml" title="Atom" href="{$atom_url}" cond="$rss_url" />
|
||||
<link rel="alternate" type="application/atom+xml" title="Site Atom" href="{$general_atom_url}" cond="$general_rss_url" />
|
||||
|
||||
<!-- ICONS -->
|
||||
<!-- ICONS AND OTHER LINKS -->
|
||||
<link cond="$canonical_url" rel="canonical" href="{$canonical_url}" />
|
||||
<link cond="$favicon_url" rel="shortcut icon" href="{$favicon_url}" />
|
||||
<link cond="$mobicon_url" rel="apple-touch-icon" href="{$mobicon_url}" />
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue