事实:SS 4.0.1,dnadesign / silverstripe-elemental 2.x-dev,php 7.1和Zauberfisches Vagrant box Jessy Version 3
我制作了一个元素元素,它是单个元素的持有者:
namespace R12page\Elements;
use DNADesign\Elemental\Models\BaseElement;
use SilverStripe\Forms\GridField\GridField;
use SilverStripe\Forms\GridField\GridFieldConfig_RecordEditor;
use SilverStripe\Versioned\Versioned;
use UndefinedOffset\SortableGridField\Forms\GridFieldSortableRows;
class ImageRasterElement extends BaseElement
{
private static $singular_name = 'Image Raster Element';
private static $plural_name = 'Images Raster Elements';
private static $description = 'Generates an Image Raster for multiple single Elements';
private static $table_name = 'ImageRasterElement';
private static $has_many = [
'SingleElements' => SingleElement::class
];
private static $extensions = [
Versioned::class . '.stagedversioned',
];
public function getType()
{
return 'ImageRasterElement';
}
public function getCMSFields()
{
$fields = parent::getCMSFields();
$singleElements = $this->SingleElements();
$singleElementGridConfig = GridFieldConfig_RecordEditor::create();
$singleElementGridConfig->addComponent(new GridFieldSortableRows('SortOrder'));
$singleElementGrid = GridField::create('SingleElements', 'Single Elements of this Page', $singleElements, $singleElementGridConfig);
$fields->addFieldsToTab('Root.Main', $singleElementGrid);
return $fields;
}
}
这个元素有很多单个元素:它们看起来像:
namespace R12page\Elements;
use R12page\Model\News;
use R12page\Model\People;
use R12page\Model\References;
use SilverStripe\ORM\DataObject;
use SilverStripe\Versioned\Versioned;
class SingleElement extends DataObject
{
private static $table_name = 'SingleElement';
private static $db = [
'Reference' => 'Boolean',
'People' => 'Boolean',
'News' => 'Boolean',
'SortOrder' => 'Int'
];
private static $has_one = [
'News' => News::class,
'People' => People::class,
'Reference' => References::class,
'ImageRasterElements' => ImageRasterElement::class
];
private static $summary_fields = [
'News.Headline' => 'News',
'People.Name' => 'People',
'Reference.Headline' => 'Reference'
];
private static $extensions = [
Versioned::class . '.stagedversioned',
];
}
每个单个元素都有一个数据对象的has_one。看起来像:
namespace R12page\Model;
use R12page\Elements\SingleElement;
use SilverStripe\ORM\DataObject;
use SilverStripe\Versioned\Versioned;
class News extends DataObject
{
private static $table_name = 'News';
private static $db = [
'Headline' => 'Varchar',
'SubHeadline' => 'Varchar',
'Date' => 'Date',
'DatePublished' => 'Date',
'Content' => 'HTMLText',
'IsActiv' => 'Boolean',
'DisplayOnHomePage' => 'Boolean'
];
private static $has_one = [
'Mobile' => Size::class,
'Screen' => Size::Class
];
private static $has_many = [
'SingleElements' => SingleElement::class
];
private static $owns = [
'SingleElements'
];
private static $summary_fields = [
'Headline' => 'Headline',
'Mobile.Title' => 'Mobile',
'Screen.Title' => 'Screen'
];
private static $extensions = [
Versioned::class . '.stagedversioned',
];
}
到目前为止一切顺利。这就是管理区域中的样子。
当我刷新页面时,我可以看到页面的内容,我可以保存它没有任何问题。如果使用php_debug一切看起来不错。我也不知道控制台中的错误信息与我遇到的问题有关。我只是得到警告:
但我认为警告应该不是问题。确切地说,我得到一个错误,因为没有加载字体。
请帮我调试一下。我尝试过这一天的工作。我无法确定我遇到的问题。
这是我回复的回应:
对我而言看起来还不错。
我可以确认的观点:
元素适用于全新安装。
如果我切换到实时模式,则没有任何变化。
如果我尝试使用与elemental一起提供的内容元素,则它具有相同的行为。