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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Mp3 player


Go to End


19 Posts   5723 Views

Avatar
Maariak

Community Member, 37 Posts

15 March 2011 at 11:50pm

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.

Avatar
Maariak

Community Member, 37 Posts

15 March 2011 at 11:53pm

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

Avatar
Maariak

Community Member, 37 Posts

17 March 2011 at 8:21am

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.

Avatar
Maariak

Community Member, 37 Posts

17 March 2011 at 8:38am

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.

Avatar
davidm2010

Community Member, 107 Posts

17 March 2011 at 9:07am

Edited: 17/03/2011 9:16am

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

Avatar
UncleCheese

Forum Moderator, 4102 Posts

17 March 2011 at 9:17am

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.

Avatar
Maariak

Community Member, 37 Posts

17 March 2011 at 9:37am

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.

Avatar
Maariak

Community Member, 37 Posts

17 March 2011 at 10:19am

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