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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Blog Module /

Discuss the Blog Module.

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

Embed YouTube videos


Go to End


10 Posts   7158 Views

Avatar
geist

Community Member, 7 Posts

5 February 2010 at 9:24am

Edited: 05/02/2010 9:25am

I hope, this works:

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

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

Avatar
carlos

Community Member, 42 Posts

9 February 2010 at 5:20pm

Hi there,

you can add any type of fields to DataObjects.

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

<?php

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.

Go to Top