Jump to:

23480 Posts in 18951 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Best method for adding flash video via new field in CMS

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 1041 Views
  • theoldlr
    Avatar
    Community Member
    103 Posts

    Best method for adding flash video via new field in CMS Link to this post

    I want to add a 2nd field in the CMS for the Page Type intended for flash video. My initial thought was to just add a 2nd HtmlEditorField and use the convenient insert flash object tool. (I want a separate field because in some cases I have a control on the page and want the video to be last on the page)

    I used this code:

    class Page extends SiteTree {
       
       public static $db = array(
       'Video' => 'HtmlText'
    );
       
       public static $has_one = array(
    'Photo' => 'Image'
       );
       
    //Add CMS Field for Image and Video
    function getCMSFields() {
    $fields = parent::getCMSFields();

    $fields->addFieldToTab('Root.Content.Images', new ImageField('Photo'));
    $fields->addFieldToTab('Root.Content.Main', new HtmlEditorField('Video'));
    return $fields;

    After adding the 'Video' => 'HtmlText' in the $db array I started getting javascript errors in the cms and it would not allow me to save any content.

    Can someone explain what I am doing wrong, and if you know of one, what a better method would be for easily adding a flash video via the cms might be?

    Thanks in advance!

  • yurigoul
    Avatar
    Community Member
    202 Posts

    Re: Best method for adding flash video via new field in CMS Link to this post

    Try using

    'Video' => 'HTMLText'

    EDIT: What about using a document upload field and using swfobject2 and $Document.AbsoluteURL or $Document.Filename to add the content to your page? If your videos could have different sizes you also need fields to give the height and width. Maybe you can tweak the document upload field to only show and upload swf - but I sometimes my guesses are totally wrong Anyway: if you are the only one adding content to the site is does not matter much.

    http://doc.silverstripe.org/doku.php?id=recipies:adding-a-file-to-a-page

  • theoldlr
    Avatar
    Community Member
    103 Posts

    Re: Best method for adding flash video via new field in CMS Link to this post

    Thanks for pointing out my syntactical error! Now it works fine. Also, a good idea with the file upload field, but in my case I may have more than 1 video and need to add/change captions so an HtmlEditorField is probably best for my use. However, I will probably try this idea on a future site.

    1041 Views
Page: 1
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.