mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 06:05:56 +00:00
MINOR: Modify VirtualPage to work with lazy loading.
This commit is contained in:
parent
98a0331a48
commit
db3332e629
@ -69,11 +69,12 @@ class VirtualPage extends Page {
|
|||||||
* @return SiteTree Returns the linked page, or failing that, a new object.
|
* @return SiteTree Returns the linked page, or failing that, a new object.
|
||||||
*/
|
*/
|
||||||
function CopyContentFrom() {
|
function CopyContentFrom() {
|
||||||
if(empty($this->record['CopyContentFromID'])) return new SiteTree();
|
$copyContentFromID = $this->CopyContentFromID;
|
||||||
|
if(!$copyContentFromID) return new SiteTree();
|
||||||
|
|
||||||
if(!isset($this->components['CopyContentFrom'])) {
|
if(!isset($this->components['CopyContentFrom'])) {
|
||||||
$this->components['CopyContentFrom'] = DataObject::get_by_id("SiteTree",
|
$this->components['CopyContentFrom'] = DataObject::get_by_id("SiteTree",
|
||||||
$this->record['CopyContentFromID']);
|
$copyContentFromID);
|
||||||
|
|
||||||
// Don't let VirtualPages point to other VirtualPages
|
// Don't let VirtualPages point to other VirtualPages
|
||||||
if($this->components['CopyContentFrom'] instanceof VirtualPage) {
|
if($this->components['CopyContentFrom'] instanceof VirtualPage) {
|
||||||
@ -89,7 +90,7 @@ class VirtualPage extends Page {
|
|||||||
return $this->components['CopyContentFrom'] ? $this->components['CopyContentFrom'] : new SiteTree();
|
return $this->components['CopyContentFrom'] ? $this->components['CopyContentFrom'] : new SiteTree();
|
||||||
}
|
}
|
||||||
function setCopyContentFromID($val) {
|
function setCopyContentFromID($val) {
|
||||||
if(DataObject::get_by_id('SiteTree', $val) instanceof VirtualPage) $val = 0;
|
if($val && DataObject::get_by_id('SiteTree', $val) instanceof VirtualPage) $val = 0;
|
||||||
return $this->setField("CopyContentFromID", $val);
|
return $this->setField("CopyContentFromID", $val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user