Provides the ability to preview DataObjects in the CMS
PHP JavaScript CSS
Latest commit a8f258c Nov 12, 2015 @stecman stecman Use relative paths for previews to support sites in sub dirs
The use of an absolute path caused the dataobject previewer iframe to
point to an incorrect path when a site was not located directly in the
document root. A 404 page would display in all preview iframes instead
of the preview that had been rendered.
Permalink
Failed to load latest commit information.
cache
code
css
js
resources
.gitignore
LICENSE
README.md
_config.php
composer.json

README.md

SilverStripe DataObject Preview

Provides the ability to preview DataObjects in the CMS.

Installation (with composer)

$ composer require heyday/silverstripe-dataobjectpreview

Example

DataObject Preview 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