gorriecoe/silverstripe-embed

Adds embed and video a dataobject along with dataextension to apply embed to existing objects.

Installs: 10 720

Dependents: 3

Suggesters: 0

Security: 0

Stars: 1

Watchers: 2

Forks: 11

Open Issues: 5

Type:silverstripe-vendormodule

1.0.2 2018-07-10 03:54 UTC

This package is auto-updated.

Last update: 2024-03-20 18:19:18 UTC


README

ko-fi

Adds embed and video a dataobject along with dataextension to apply embed to existing objects.

Installation

Composer is the recommended way of installing SilverStripe modules.

composer require gorriecoe/silverstripe-embed

Requirements

  • silverstripe/framework ^4.0

Maintainers

Usage

Relationship to Embed Dataobjects

use gorriecoe\Embed\Models\Embed;

class ClassName extends DataObject
{
    private static $has_one = [
        'Embed' => Embed::class,
        'Video' => Video::class
    ];

    public function getCMSFields()
    {
        ...
        $fields->addFieldsToTab(
            'Main',
            [
                HasOneButtonField::create(
                    'Embed',
                    'Embed',
                    $this
                ),
                HasOneButtonField::create(
                    'Video',
                    'Video',
                    $this
                )
            ]
        );
        ...
    }
}

Update current DataObject to be Embeddable with DataExtension

use gorriecoe\Embed\Extensions\Embeddable;

class ClassName extends DataObject
{
    private static $extensions = [
        Embeddable::class,
    ];

    /**
     * List the allowed included embed types.  If null all are allowed.
     * @var array
     */
    private static $allowed_embed_types = [
        'video',
        'photo'
    ];

    /**
     * Defines tab to insert the embed fields into.
     * @var string
     */
    private static $embed_tab = 'Main';
}