7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » FileDataObjectManger no output
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 579 Views |
-
FileDataObjectManger no output

9 December 2009 at 5:25am
I am having an issue that despite having all the files showing up with in the back end, I can't get them to render on the front end...
This is my code
class Download extends DataObject {
static $db = array(
'date' => 'Text',
'description' => 'Text'
);
static $has_one = array(
'TheDownload' => 'File'
);
static $belongs_many_many = array (
'Download' => 'Downloads'
);
function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push(new TextField('date','Date Created'));
$fields->push(new TextField('description','Description of file'));
$fields->push(new FileIFrameField('TheDownload'));
return $fields;
}class Downloads extends Page {
static $db = array();
static $has_one = array();
static $many_many = array(
'TheDownloads' => 'Download');
function getCMSFields() {
$fields = parent::getCMSFields();
$manager = new FileDataObjectManager(
$this, // Controller
'TheDownloads', // Source name
'Download', // Source class
'TheDownload', // File name on DataObject
array(
'Date' => 'Date',
'Description' => 'Description',
), // Headings
'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
// Filter clause
// Sort clause
// Join clause
);
$fields->addFieldToTab("Root.Content.Resources",$manager);
return $fields;
}<table class="downloads">
<tr>
<th>Date</th>
<th>Description</th>
<th>Size</th>
<th>Download</th>
</tr>
<% control TheDownloads %>
<tr>
<td>$Date</td>
<td>$Description</td>
<td>$TheDownload.Size</td>
<td><a href="$TheDownload.URL" target="_new"><img src="/themes/howell/images/icons/page_white_acrobat.png" alt="Download "/></a></td>
</tr>
<% end_control %>
</table>Any ideas as to what I am doing? It just outputs the table headers and nothing else -> http://howellv2.stagedsite.net/committee-minutes/?flush=all
-
Re: FileDataObjectManger no output

9 December 2009 at 5:56am
The biggest issue you have is that you're using a FileDOM to manage a many_many relationship, when you should be using a MMFileDOM.
The other thing is that your naming conventions are extremely confusing and redundant. I wouldn't be surprised if that's tripping up the ORM. You have two fields named "TheDownload".. "Download" is a belongs_many_many field and it's also a class. I don't know how you keep track of all that!
| 579 Views | ||
|
Page:
1
|
Go to Top |

