7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » New Feature: Audio and Video
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | Next > | |
| Author | Topic: | 21888 Views |
-
Re: New Feature: Audio and Video

15 May 2009 at 12:21am Last edited: 15 May 2009 12:45am
Hi Uncle Cheese,
this looks really great. thank you for your work.
while using i get the following error:
"[User Error] Object::__call() Method 'forTemplate' not found in class 'File'"
this happens, if i use the variable $Attachment in my template, which is the object property for my file.
i also miss the .js and .swf-includes in my html-file. i followed your description on http://doc.silverstripe.com/doku.php?id=modules:dataobjectmanager and on youtube.
thank you,
roelfsche -
Re: New Feature: Audio and Video

16 May 2009 at 11:41pm Last edited: 17 May 2009 12:04am
i tried an mp3 file.
my code looks as follows:
class AudioFile extends DataObject {
public static $db = array(
'Name' => 'Text',
'Beschreibung' => 'Text'
);
static $has_one = array(
'Attachment' => 'File',
'AudioSeite' => 'AudioPage'
);function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push( new TextField( 'Name', 'Titelname' ) );
$fields->push( new TextField( 'Beschreibung', 'Beschreibung' ) );
$fields->push( new FileIFrameField( 'Track', 'MP3-File') );
return $fields;
}}
class AudioPage extends Page
{
public static $db = array();public static $has_one = array();
static $has_many = array('AudioFiles' => 'AudioFile');function getCMSFields()
{
$fields = parent::getCMSFields();$manager = new FileDataObjectManager($this, 'AudioFiles', 'AudioFile', 'Attachment', array('Name' => 'Name', 'Beschreibung' => 'Beschreibung'), 'getCMSFields_forPopup'/* new FieldSet(new TextField('Beschreibung', 'Beschreibung'), new FileIFrameField('Track'))*/
);$manager->setAllowedFileTypes(array('mp3'));
$manager->setBrowseButtonText('MP3 Datei hochladen');
$manager->allowUploadFolderSelection();$fields->addFieldToTab('Root.Content.Tracks', $manager);
return $fields;
}}
the AudioPage.ss (exactly the Layout-snippet) only has the following lines:
<% control AudioFiles %>
<h3>$Name</h3>
<p>$Beschreibung</p>
$Attachment
<% end_control %>thank you,
roelfsche -
Re: New Feature: Audio and Video

17 May 2009 at 12:57pm Last edited: 17 May 2009 12:57pm
Can you check your DB and verify that the file was stored with ClassName "MP3?"
You're on the latest SVN, I assume. I haven't deployed this to the ZIP file download yet.
-
Re: New Feature: Audio and Video

18 May 2009 at 12:08am Last edited: 18 May 2009 12:26am
hi uncle cheese,
you are right. the reason is the 'ClassName' field in the file table.
if i upload with silverstripe's 'files and folder' functionality the files get as ClassName 'file'. if i upload from your swf-uploader by directly choosing files from my pc the ClassName-field has 'MP3' as value and it works fine.
may be the possibility of choosing existing files in the swf-uploader should filter possible uploaded files by ClassName == 'MP3' to choose for displaying (eg. listening ;-))?
anyway, it's a great functionality.
roelfsche -
Re: New Feature: Audio and Video

18 May 2009 at 3:41am
Yeah, I should have mentioned that. That's one reason it's just in SVN right now and not in the official release. I plan to clean all that up. That said, if you do have a page of strictly audio files, just use
$has_many = array ('AudioFiles' => 'MP3');
instead of
$has_many = array ('AudioFiles' => 'File');That way you're not relying on DOM to sniff out the upgrade. You're doing it manually.
-
Re: New Feature: Audio and Video

20 May 2009 at 12:30pm
Very nice implementation Uncle Cheese. I have it working pretty well. The only issue I have is that the VideoThumnail is not actually generated. I am not sure why. The permissions seem to be right on the assets/uploads folder and SS can put other files in there. Also I wanted to know what developer too /code editor you were using on the video. I am looking for a good one that isn't Dreamweaver.
| 21888 Views | ||
| Go to Top | Next > |

