BUGFIX a VirtualPage will now use the correct template

BUGFIX a VirtualPage can now access the custom fields of its parent

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@82591 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Tom Rix 2009-07-24 00:23:12 +00:00
parent d5d8cf15f6
commit 012427d6c8

View File

@ -121,6 +121,25 @@ class VirtualPage extends Page {
$this->$virtualField = $source->$virtualField;
}
}
/**
* Allow attributes on the master page to pass
* through to the virtual page
*
* @param string $field
* @return mixed
*/
function __get($field) {
$return = parent::__get($field);
if ($return === null) {
if($this->copyContentFrom()->hasMethod($funcName = "get$field")) {
$return = $this->copyContentFrom()->$funcName();
} else if($this->copyContentFrom()->hasField($field)) {
$return = $this->copyContentFrom()->getField($field);
}
}
return $return;
}
}
/**
@ -142,6 +161,12 @@ class VirtualPage_Controller extends Page_Controller {
return;
}
function getViewer($action) {
$name = get_class($this->CopyContentFrom())."_Controller";
$controller = new $name();
return $controller->getViewer($action);
}
/**
* When the virtualpage is loaded, check to see if the versions are the same
* if not, reload the content.