Jump to:

7939 Posts in 1472 Topics by 944 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: 2953 Views
  • Maariak
    Avatar
    Community Member
    20 Posts

    Re: Mp3 player Link to this post

    Yes I did. But the problem is somewhere in there, because there's no MP3Page mentioned in the list after /dev/build though other Pages are.

  • Maariak
    Avatar
    Community Member
    20 Posts

    Re: Mp3 player Link to this post

    I mean in the page that tells what database tables/records have been created

  • Maariak
    Avatar
    Community Member
    20 Posts

    Re: Mp3 player Link to this post

    I tried replacing the codes with quite similar codes in this topic http://silverstripe.org/dataobjectmanager-module-forum/show/13316?start=0, because there were minor differences between them. But of course it didn't help, because that's not where the problem is. Still dev/build seem not to do anything. I've managed to make other pagetypes, so I have to figure out what I'm doing wrong with AudioPage.

  • Maariak
    Avatar
    Community Member
    20 Posts

    Re: Mp3 player Link to this post

    Well, that's clear the problem has something to do with AudioFile.php (where there's that $db), not with that exact file, but something related to it, because dev/build doesn't build a new page type. So I'm very interested to know where I could look for the problem. Do I need to do something to DOM or Uploadify? They should be in right places and with the right folder names.

  • davidm2010
    Avatar
    Community Member
    107 Posts

    Re: Mp3 player Link to this post

    I built a page for audio, I am not a coder, but have had some mild success with SS. So, in the mysite->code (.php files), you create the page type. In the folder themes->theme name->templates->layout is where you put the page layout (.ss file). Where theme name is the name of the theme you are using.

    When you create a new page, look for the new page type.

    Here are my examples. I would attach but can't upload. copy between the broken lines. The page type for this example will be Audio Page

    Goes in mysite->code

    File name: AudioFile.php
    --------------------------------copy below---------------------------------------------------
    <?php

    class AudioFile extends DataObject {

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

    static $has_one = array (
    'AudioPage' => 'AudioPage',
    'File' => 'MP3'
    );

    public function getCMSFields() {
    $f = new FieldSet (
    new Textfield('SongTitle'),
    new TextareaField('Description'),
    $u = new FileUploadField('File')
    );
    $u->setFileTypes(array('mp3'));
    return $f;
    }
    }
    ?>
    ----------------------------stop above this line-------------------------------

    Goes in mysite->code
    Filename: AudioPage.php
    --------------------------------copy below---------------------------------------------------

    <?php

    class AudioPage extends Page {

    static $has_many = array (
    'AudioFiles' => 'AudioFile'
    );

    public function getCMSFields() {
    $f = parent::getCMSFields();
    $f->addFieldToTab("Root.Content.Audio", new FileDataObjectManager($this));
    return $f;
    }
    }
    class AudioPage_Controller extends Page_Controller {}
    ?>
    ----------------------------stop above this line-------------------------------

    Now, for the ss file that goes in: themes->theme name->templates->layout (theme name being the name of the theme you are going to use, example: blackcandy)

    Filename: AudioPage.ss

    --------------------------------copy below---------------------------------------------------

    <div class="typography">
        <% if Level(2) %>
           <% include BreadCrumbs %>
        <% end_if %>
    <h3>$Title</h3>
             $Content    

    <table width="750" border="0" cellspacing="0" cellpadding="0">
    <% control AudioFiles %>
    <tr>
    <th width="50" scope="col">$File.Player</th>
    <th width="350" scope="col"><p><b>$SongTitle</p></b></th>
    <th width="350"scope="col"><p>$Description</p></th>
    </tr>
    <% end_control %>
    </table>

    </div>

    ----------------------------stop above this line-------------------------------

    Run dev/code/build?flush=1, go to admin page, create and look for audio page as the type.

    I tried to step you through and hope I didn't miss anything. Let me know if it works.

    DM

  • UncleCheese
    Avatar
    4085 Posts

    Re: Mp3 player Link to this post

    You need to make sure the file name is the same as the class name. Otherwise, it won't include the file in the manifest.

    This won't work:

    audiofile.php

    class AudioFile extends DataObject {}

    has to be:

    AudioFile.php

    That could be your problem.

  • Maariak
    Avatar
    Community Member
    20 Posts

    Re: Mp3 player Link to this post

    The problem wasn't with the names, they were right. The code above is quite similar to mine, but what I realize from it is the <?php -- ?> tag, I added that... and now it's working, wohoo! ;) But why on earth didn't I realize that it was the part that I had in other my files, but not in these files... But thanks a lot for helping me! Now the problem is, that error occurs when downloading mp3 file, but I think that's the problem with max-size that I've read about, I'll go and fix that.

  • Maariak
    Avatar
    Community Member
    20 Posts

    Re: Mp3 player Link to this post

    Ok, back to problem searching.. The problem wasn't with the max size, it says just "HTTP Error". I found these topics related to the subject, so maybe I'll find the answer
    http://www.silverstripe.org/dataobjectmanager-module-forum/show/14597
    http://www.silverstripe.org/dataobjectmanager-module-forum/show/15829

    2953 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.