Jump to:

7940 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Mp3 player

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2 3
Go to End
Author Topic: 3164 Views
  • Maariak
    Avatar
    Community Member
    20 Posts

    Mp3 player Link to this post

    I'm new with SS and trying to figure out things with the system, and what things are related to each other. I've already had a huge amount of help when reading old topics and reading tutorials, but the problem is with the language, though I can quite well read English, there are so many special terms that makes it's difficult with the tutorials, understanding all with different modules and extensions.

    So, when I want e.g. to make it possible to upload a audiofile (mp3-file) to the site to play, I need DOM-module to manage the objects? But don't need FFmpeg to work in the server, if I'm not working with videos, converting them to other form? Do I need uploadify? (Well, I need it maybe to make it possible uploading other files, but with these mp3's?) In which tutorial or thread I find it explained what I need to add to the code to make upload-fields to appear in cms and how to make the player play the audiofile in the site when uploaded and saved? I'm working with site, where I need possibility to add audiofiles to play in different pages with the text and sometimes images aswell. I found many topics related to this audiofile-issue, but sometimes the difficulties with the language is making me just more confused..

  • UncleCheese
    Avatar
    4085 Posts

    Re: Mp3 player Link to this post

    Hi, Maariak,

    Setting up an MP3 page is pretty simple. You don't need FFMPEG, as long as you upload mp3 files. FFMPEG would allow you to upload other types of files and convert them to mp3, but as long as you're uploading in mp3 format, you'll be fine.

    Try this code.. You'll need DataObjectManager and Uploadify.

    MP3Page.php

    class MP3Page extends Page {

    static $has_many = array (
    'MP3Files' => 'MP3File'
    );

    public function getCMSFields() {
    $f = parent::getCMSFields();
    $f->addFieldToTab("Root.Content.MP3s", $dom = new FileDataObjectManager($this,'MP3Files','MP3File'));
    $dom->setAllowedFileTypes(array('mp3'));
    return $f;
    }

    }

    MP3File.php

    class MP3File extends DataObject {

    static $db = array (
    'Title' => 'Varchar',
    'Description' => 'Text'
    );

    static $has_one = array (
    'MP3Page' => 'MP3'
    );

    public function getCMSFields() {
    $f = new FieldSet (
    new TextField('Title'),
    new TextareaField('Description'),
    $u = new FileUploadField('MP3')
    );
    $u->setFileTypes(array('mp3'));
    return $f;
    }
    }

    MP3Page.ss

    <% control MP3Files %>
    $Player
    <% end_control %>

  • Maariak
    Avatar
    Community Member
    20 Posts

    Re: Mp3 player Link to this post

    Thanks! Just want to make sure do I put these in the folders where the other stuff are, mysite, templates etc. or under those folders in DOM or Uploadify folders? Well, I can of course try and test tomorrow in which way does it work

  • UncleCheese
    Avatar
    4085 Posts

    Re: Mp3 player Link to this post

    The .php files should go in your_project/code and the .ss files should go in your_theme/Layout. Good luck!

  • Maariak
    Avatar
    Community Member
    20 Posts

    Re: Mp3 player Link to this post

    Thanks again, your answers are understandable even in my english There's still some thing I didn't get right, because the upload field doesn't appear in cms. I've got the .ss file under themes/(mytheme)/templates/Layout and and .php files under mysite/code, that should be the right place? And DOM (in dataobject_manager folder) and uploadify (in uploadify folder) are in the root. Is there some update needed, or do I need to modify other codes somehow?

  • UncleCheese
    Avatar
    4085 Posts

    Re: Mp3 player Link to this post

    When you create an MP3Page, you don't have a tab for "MP3s?"

  • Maariak
    Avatar
    Community Member
    20 Posts

    Re: Mp3 player Link to this post

    When I'm creating a new page, there's no such option than MP3Page..

  • UncleCheese
    Avatar
    4085 Posts

    Re: Mp3 player Link to this post

    You ran a /dev/build?

    3164 Views
Page: 1 2 3
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.