mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
FIX Use correct canonical tag on VirtualPage (#2688)
This commit is contained in:
parent
9f7262f99d
commit
480baa6ef8
@ -143,9 +143,10 @@ class VirtualPage extends Page
|
||||
$copied = $this->CopyContentFrom();
|
||||
if ($copied && $copied->exists()) {
|
||||
$tags['canonical'] = [
|
||||
'tag' => 'link',
|
||||
'attributes' => [
|
||||
'rel' => 'canonical',
|
||||
'content' => $copied->AbsoluteLink(),
|
||||
'href' => $copied->AbsoluteLink(),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ use SilverStripe\CMS\Controllers\ModelAsController;
|
||||
use SilverStripe\CMS\Model\RedirectorPage;
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\CMS\Model\VirtualPage;
|
||||
use SilverStripe\Control\ContentNegotiator;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
@ -93,6 +94,22 @@ class VirtualPageTest extends FunctionalTest
|
||||
$this->assertEquals("<p>New content</p>", $vp2->Content);
|
||||
}
|
||||
|
||||
public function testMetaTags()
|
||||
{
|
||||
$this->logInWithPermission('ADMIN');
|
||||
$master = $this->objFromFixture('Page', 'master');
|
||||
$vp1 = $this->objFromFixture(VirtualPage::class, 'vp1');
|
||||
|
||||
// Test with title
|
||||
$meta = $vp1->MetaTags();
|
||||
$charset = Config::inst()->get(ContentNegotiator::class, 'encoding');
|
||||
$this->assertContains('<meta http-equiv="Content-Type" content="text/html; charset='.$charset.'"', $meta);
|
||||
$this->assertContains('<link rel="canonical" href="'.$master->AbsoluteLink().'"', $meta);
|
||||
$this->assertContains('<meta name="x-page-id" content="'.$vp1->ID.'"', $meta);
|
||||
$this->assertContains('<meta name="x-cms-edit-link" content="'.$vp1->CMSEditLink().'"', $meta);
|
||||
$this->assertContains('<title>'.$master->Title.'</title>', $meta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that, after you publish the source page of a virtual page, all the already published
|
||||
* virtual pages are published
|
||||
|
Loading…
Reference in New Issue
Block a user