Use SiteTree instead of Page class in more places. Allows developers to extend SiteTree directly.

This commit is contained in:
Mike Cochrane 2017-01-03 20:38:45 +13:00
parent a8732efd7a
commit 2108d8ef08
2 changed files with 3 additions and 5 deletions

View File

@ -59,7 +59,6 @@ use SilverStripe\Security\SecurityToken;
use SilverStripe\View\ArrayData;
use SilverStripe\View\Requirements;
use Translatable;
use Page;
use Zend_Cache;
use InvalidArgumentException;
@ -352,7 +351,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
public function LinkPreview() {
$record = $this->getRecord($this->currentPageID());
$baseLink = Director::absoluteBaseURL();
if ($record && $record instanceof Page) {
if ($record && $record instanceof SiteTree) {
// if we are an external redirector don't show a link
if ($record instanceof RedirectorPage && $record->RedirectionType == 'External') {
$baseLink = false;

5
code/Controllers/ContentController.php Executable file → Normal file
View File

@ -28,7 +28,6 @@ use SilverStripe\SiteConfig\SiteConfig;
use SilverStripe\View\ArrayData;
use SilverStripe\View\Requirements;
use SilverStripe\View\SSViewer;
use Page;
use Translatable;
/**
@ -67,7 +66,7 @@ class ContentController extends Controller {
*/
public function __construct($dataRecord = null) {
if(!$dataRecord) {
$dataRecord = new Page();
$dataRecord = new SiteTree();
if($this->hasMethod("Title")) {
$dataRecord->Title = $this->Title();
}
@ -277,7 +276,7 @@ class ContentController extends Controller {
// Remove all entries the can not be viewed by the current user
// We might need to create a show in menu permission
if(isset($result)) {
if(isset($result)) {
foreach($result as $page) {
if($page->canView()) {
$visible[] = $page;