Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » FileDataObjectManger no output

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 656 Views
  • 3pointross
    Avatar
    Community Member
    18 Posts

    FileDataObjectManger no output Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: FileDataObjectManger no output Link to this post

    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!

    656 Views
Page: 1
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.