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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

FileDataObjectManger no output


Reply

2 Posts   705 Views

Avatar
3pointross

9 December 2009 at 5:25am Community Member, 19 Posts

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

Avatar
UncleCheese

9 December 2009 at 5:56am 4085 Posts

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!