Jump to:

7938 Posts in 1541 Topics by 945 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » New Feature: Audio and Video

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Go to End
Author Topic: 24661 Views
  • Roelfsche
    Avatar
    25 Posts

    Re: New Feature: Audio and Video Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: New Feature: Audio and Video Link to this post

    Did you upload an mp3 or FLV?

  • Roelfsche
    Avatar
    25 Posts

    Re: New Feature: Audio and Video Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: New Feature: Audio and Video Link to this post

    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.

  • Roelfsche
    Avatar
    25 Posts

    Re: New Feature: Audio and Video Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: New Feature: Audio and Video Link to this post

    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.

  • Roelfsche
    Avatar
    25 Posts

    Re: New Feature: Audio and Video Link to this post

    that's a good idea.
    thank you.
    roelfsche

  • micahsheets
    Avatar
    Community Member
    164 Posts

    Re: New Feature: Audio and Video Link to this post

    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.

    24661 Views
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
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.