mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
Merge pull request #2647 from muskie9/bugfix/virtualPageCanonical2637
UPDATE generate canonical via MetaComponents
This commit is contained in:
commit
f230adcc69
@ -134,23 +134,22 @@ class VirtualPage extends Page
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For VirtualPage, add a canonical link tag linking to the original page
|
* @return array
|
||||||
* See TRAC #6828 & http://support.google.com/webmasters/bin/answer.py?hl=en&answer=139394
|
|
||||||
*
|
|
||||||
* @param boolean $includeTitle Show default <title>-tag, set to false for custom templating
|
|
||||||
* @return string The XHTML metatags
|
|
||||||
*/
|
*/
|
||||||
public function MetaTags($includeTitle = true)
|
public function MetaComponents()
|
||||||
{
|
{
|
||||||
$tags = parent::MetaTags($includeTitle);
|
$tags = parent::MetaComponents();
|
||||||
|
|
||||||
$copied = $this->CopyContentFrom();
|
$copied = $this->CopyContentFrom();
|
||||||
if ($copied && $copied->exists()) {
|
if ($copied && $copied->exists()) {
|
||||||
$tags .= HTML::createTag('link', [
|
$tags['canonical'] = [
|
||||||
'rel' => 'canonical',
|
'attributes' => [
|
||||||
'href' => $copied->Link()
|
'rel' => 'canonical',
|
||||||
]);
|
'content' => $copied->AbsoluteLink(),
|
||||||
$tags .= "\n";
|
],
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $tags;
|
return $tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user