21293 Posts in 5733 Topics by 2602 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, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 848 Views |
-
Best method for adding flash video via new field in CMS

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!
-
Re: Best method for adding flash video via new field in CMS

20 December 2009 at 2:24am Last edited: 20 December 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.
http://doc.silverstripe.org/doku.php?id=recipies:adding-a-file-to-a-page
-
Re: Best method for adding flash video via new field in CMS

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.
| 848 Views | ||
|
Page:
1
|
Go to Top |

