Jump to:

1851 Posts in 1606 Topics by 561 members

Blog Module

SilverStripe Forums » Blog Module » Embed YouTube videos

Discuss the Blog Module.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2
Go to End
Author Topic: 4758 Views
  • geist
    Community Member
    7 Posts

    Re: Embed YouTube videos Link to this post

    I hope, this works:

    Add BlogEntry::allow_wysiwyg_editing(); to /mysite/_config.php

    And comment out this two lines in the BlogEntry.php:
    $fields->addFieldToTab("Root.Content.Main", new TextareaField("Content", _t("BlogEntry.CN", "Content"), 20));

  • carlos
    Community Member
    41 Posts

    Re: Embed YouTube videos Link to this post

    Hi there,

    you can add any type of fields to DataObjects.

    Here is an example of a DataObject to embed videos from youtube


    class Videos extends DataObject {
       static $db = array(
          'Title' => 'Varchar(255)',
          'Description' => 'Text',
          'YouTubeCode' => 'HTMLText' //code to embed the video
       function getCMSFields() {
           $fields = parent::getCMSFields();

           $fields->addFieldToTab('Root.Main', new TextField('Title', 'Video Title'));
          $fields->addFieldToTab('Root.Main', new TextareaField('YouTubeCode', 'YouTube code to embed'));
          return $fields;


    you can add more fields if you want.
    Then just add $YouTubeCode in your template, as usual.

Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.