Jump to:

7939 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » FileDataObjectManager - question?

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2 3 4
Go to End
Author Topic: 4204 Views
  • FireMe!
    Avatar
    Community Member
    74 Posts

    Re: FileDataObjectManager - question? Link to this post

    Thanks UncleCheese that works great. thanks alot

  • ulysses
    Avatar
    Community Member
    57 Posts

    Re: FileDataObjectManager - question? Link to this post

    Can you create a PDF document gallery using the Image Gallery extention or is there another extention that can be used for this purpose.

  • UncleCheese
    Avatar
    4085 Posts

    Re: FileDataObjectManager - question? Link to this post

    I would use a FileDataObjectManager for this, and handle the gallery UI as you see fit on your template. The ResourcePage example would be a good one to follow.

  • ulysses
    Avatar
    Community Member
    57 Posts

    Re: FileDataObjectManager - question? Link to this post

    Where can I downlaod some working examples from? I have created the Resource.php & ResourcePage.php under mysite/code/ and ran dev/build. I cannot see the Resource Page type.

    Please help.

  • UncleCheese
    Avatar
    4085 Posts

    Re: FileDataObjectManager - question? Link to this post

    Can you post your code for those two classes?

  • ulysses
    Avatar
    Community Member
    57 Posts

    Re: FileDataObjectManager - question? Link to this post

    There was a } missing in the ResourcePage.php

    Now that it is added, the page type appears but when you select it, the page cannot be saved.

    Here are the 2 files:

    Resource.php

    <?php

    class Resource extends DataObject
    {
       static $db = array (
          'Name' => 'Text',
          'Description' => 'Text',
          'Category' => "Enum('Industry, Finance, Education')"
       );
       
       static $has_one = array (
          'Attachment' => 'File',
          'ResourcePage' => 'ResourcePage'
       );
       
       public function getCMSFields_forPopup()
       {
          return new FieldSet(
             new TextField('Name'),
             new TextareaField('Description'),
             new DropdownField('Category','Category', singleton('Resource')->dbObject('Category')->enumValues()),
             new FileIFrameField('Attachment')
          );
       }
    }

    ?>

    ResourcePage.php

    <?php

    class ResourcePage extends Page
    {
       static $has_many = array (
          'Resources' => 'Resource'
       );
       
       public function getCMSFields()
       {
          $f = parent::getCMSFields();
          $manager = new FileDataObjectManager(
             $this, // Controller
             'Resources', // Source name
             'Resource', // Source class
             'Attachment', // File name on DataObject
             array (
                'Name' => 'Name',
                'Description' => 'Description',
                'Category' => 'Category'
             ), // Headings
             'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
             // Filter clause
             // Sort clause
             // Join clause
          );
       }
    }

    ?>

  • UncleCheese
    Avatar
    4085 Posts

    Re: FileDataObjectManager - question? Link to this post

    Gotcha. For PDF display in a modal window, you probably want to use Lightwindow.

  • ulysses
    Avatar
    Community Member
    57 Posts

    Re: FileDataObjectManager - question? Link to this post

    OK - how do you use the lightwindow for the PDF display. Previously prior to 2.3 I was able to use the different version of image gallery which allowed for the use of both images as well as PDF files. See: http://www.sunnynook.school.nz/cms/latest-newsletter/

    Also for the resources on the Resource.php & ResourcePage.php, how can I get that code to work as per your example? How can I delete the page which had an error? I cannot delete it because I cannot select it as it shows an alert box with a page error.

    You help would be most appreciated.

    4204 Views
Page: 1 2 3 4
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.