MINOR Custom meta tags on SubsiteVirtualPages no longer get overwritten. (from r87329)

This commit is contained in:
Tom Rix 2010-03-01 21:49:50 +00:00
parent 625ab4e235
commit 93afe6e6ff
3 changed files with 34 additions and 0 deletions

View File

@ -72,6 +72,8 @@ class SubsitesVirtualPage extends VirtualPage {
foreach($fields as $k => $v) {
if($v == 'SubsiteID') unset($fields[$k]);
}
foreach(self::$db as $field => $type) if (in_array($field, $fields)) unset($fields[array_search($field, $fields)]);
return $fields;
}

View File

@ -47,6 +47,7 @@ SiteTree:
SubsiteID: =>Subsite_Template.main
linky:
Title: Linky
MetaTitle: Linky
SubsiteID: =>Subsite_Template.main
staff:
Title: Staff

View File

@ -163,4 +163,35 @@ class SubsitesVirtualPageTest extends SapphireTest {
}
}
/**
* Test custom metadata. Reloading Content should not
* obliterate our custom fields
*/
function testCustomMetadata() {
Subsite::$write_hostmap = false;
$subsite = $this->objFromFixture('Subsite_Template', 'main');
Subsite::changeSubsite($subsite->ID);
$orig = $this->objFromFixture('SiteTree', 'linky');
$svp = new SubsitesVirtualPage();
$svp->CopyContentFromID = $orig->ID;
$svp->SubsiteID = $subsite->ID;
$svp->URLSegment = 'linky-'.rand();
$svp->write();
$this->assertEquals($svp->MetaTitle, 'Linky');
$svp->CustomMetaTitle = 'SVPTitle';
$svp->write();
$this->assertEquals($svp->MetaTitle, 'SVPTitle');
$svp->copyFrom($svp->CopyContentFrom());
$svp->write();
$this->assertEquals($svp->MetaTitle, 'SVPTitle');
}
}