silverstripe-webpack/app/src/Pages/Page.php

47 lines
1.1 KiB
PHP
Raw Normal View History

2018-04-21 06:29:32 +02:00
<?php
// vendor/silverstripe/errorpage/src/ErrorPage.php
// extends global Page class
//namespace Site\Pages;
use SilverStripe\CMS\Model\SiteTree;
use DNADesign\Elemental\Models\ElementContent;
2018-04-21 06:29:32 +02:00
class Page extends SiteTree
{
private static $default_container_class = 'container';
public static function DefaultContainer()
{
return self::config()->get('default_container_class');
}
/*
* Shows custom summary of the post, otherwise
* Displays summary of the first content element
*/
public function Summary($wordsToDisplay = 30)
{
$summary = $this->getField('Summary');
if ($summary) {
return $summary;
}
$element = ElementContent::get()->filter([
'ParentID' => $this->ElementalArea()->ID,
'HTML:not' => [null],
])->first();
if ($element) {
return $element->dbObject('HTML')->Summary($wordsToDisplay);
}
return false;
}
public function CSSClass()
{
return str_replace(['\\'], '-', $this->getField('ClassName'));
}
2018-04-21 06:29:32 +02:00
}