Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

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

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

Best method for adding flash video via new field in CMS

Go to End

3 Posts   1359 Views


Community Member, 103 Posts

19 December 2009 at 11:31am

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!


Community Member, 203 Posts

20 December 2009 at 2:24am

Edited: 20/12/2009 2:30am

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.


Community Member, 103 Posts

22 December 2009 at 4:15am

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.