2017 © Pedro Peláez
 

silverstripe-module embedfield

A form field for adding oembed objects (primarily videos) to pages or dataobjects

image

nathancox/embedfield

A form field for adding oembed objects (primarily videos) to pages or dataobjects

  • Tuesday, November 14, 2017
  • by nathancox
  • Repository
  • 1 Watchers
  • 2 Stars
  • 749 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 3 Open issues
  • 3 Versions
  • 42 % Grown

The README.md

SilverStripe EmbedField

This field is designed to let users attached an oembed object (eg a YouTube video) to a page or dataobject. It stores the oembed result information in an EmbedObject for easy access from the template (or wherever you want it)., (*1)

Work in progress., (*2)

Requirements

  • SilverStripe 4.11+ or 5.x

Documentation

GitHub, (*3)

Installation Instructions

  1. Install with composer composer require nathancox/embedfield
  2. Visit yoursite.com/dev/build to rebuild the database

Usage Overview

Make a has_one relationship to an EmbedObject then create an EmbedField in getCMSFields:, (*4)

namespace {

    use SilverStripe\CMS\Model\SiteTree;
    use nathancox\EmbedField\Model\EmbedObject;
    use nathancox\EmbedField\Forms\EmbedField;

    class Page extends SiteTree
    {
        private static $db = [];

        private static $has_one = [
            'MyVideo' => EmbedObject::class
        ];

        public function getCMSFields() {
            $fields = parent::getCMSFields();

            $fields->addFieldToTab('Root.Main', EmbedField::create('MyVideoID', 'Sidebar video'));

            return $fields;
        }
    }
}

Gives us:, (*5)

example embedfield, (*6)

In the page template the video can now be embedded with $MyVideo., (*7)

Each embed type is rendered with it's own template (eg EmbedObject_video.ss and EmbedObject_photo.ss). The default templates just return the markup generated by SilverStripe's OembedResult::forTemplate(). You can override them in your theme:, (*8)

themes/mytheme/templates/nathancox/EmbedField/Model/EmbedObject_video.ss:, (*9)


<div class='flex-video self-sizing' style='padding-bottom:$AspectRatioHeight;'> $EmbedHTML </div>

This can be combined with your own CSS to make aspect ratio aware flexible video (see http://alistapart.com/article/creating-intrinsic-ratios-for-video)., (*10)

Known Issues

Issue Tracker, (*11)

The Versions

14/11 2017

dev-master

9999999-dev https://github.com/nathancox/silverstripe-embedfield

A form field for adding oembed objects (primarily videos) to pages or dataobjects

  Sources   Download

BSD-3-Clause

The Requires

 

by Nathan Cox

cms silverstripe video oembed formfield

14/11 2017

1.0.1

1.0.1.0 https://github.com/nathancox/silverstripe-embedfield

A form field for adding oembed objects (primarily videos) to pages or dataobjects

  Sources   Download

BSD-3-Clause

The Requires

 

by Nathan Cox

cms silverstripe video oembed formfield

24/11 2016

1.0.0

1.0.0.0 https://github.com/nathancox/silverstripe-embedfield

A form field for adding oembed objects (primarily videos) to pages or dataobjects

  Sources   Download

BSD-3-Clause

The Requires

 

by Nathan Cox

cms silverstripe video oembed formfield