heyday/silverstripe-dataobjectpreview
Composer 安装命令:
composer require heyday/silverstripe-dataobjectpreview
包简介
Allows preview of dataobjects in GridField
README 文档
README
Provides the ability to preview DataObjects in the CMS.
Installation (with composer)
$ composer require heyday/silverstripe-dataobjectpreview
Filesystem permissions
The cache/ directory in this module needs to be writable by PHP for DataObject Preview to work. Previews are rendered to file here to avoid repeated rendering of the same content.
When installing via Composer, you may want to add a post-install script in your project's composer.json to configure these permissions. For example:
{ // ... "scripts": { "post-install-cmd": [ "chmod 777 silverstripe-dataobjectpreview/cache" ] } }
Example
Usage
DataObjects that you want to preview must implement, DataObjectPreviewInterface, which consists of one method getPreviewHtml.
This method getPreviewHtml must return a string.
getPreviewHtml
public function getPreviewHtml() { return "<html><body>Hello</body></html>"; }
DataObjectPreviewField
getCMSFields
$fields->addFieldToTab( 'Root.Main', new DataObjectPreviewField( 'SomeDataObject', $this, new DataObjectPreviewer($generator) ) );
GridFieldDataObjectPreview
getCMSFields
$fields->addFieldsToTab( 'Root.Items', new GridField( 'Items', 'Items', $this->Items(), $config = GridFieldConfig_RelationEditor::create() ) ); $config->addComponent( new GridFieldDataObjectPreview( new DataObjectPreviewer($generator) ) );
License
SilverStripe DataObject Preview is licensed under an MIT license
统计信息
- 总下载量: 4.53k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 3
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-07-14
