Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Preview: DataObjectManager module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
Go to End
Author Topic: 58358 Views
  • robinp
    Avatar
    Community Member
    33 Posts

    Re: Preview: DataObjectManager module Link to this post

    Hi,

    I was justing try to use the setPageSize() method and it doesn't seem to be working. I can get to it work by changing the line

    protected $per_page = "5";

    Cheers

    Robin

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    That's because the page size is set in the UI in the bottom right. By changing the property per_page, you're setting the default value to that dropdown.

  • NickJacobs
    Avatar
    Community Member
    144 Posts

    Re: Preview: DataObjectManager module Link to this post

    Hi, dataobject_manager is working out great for a current site, but I need to have images resized on upload (2 sizes: thumbnail and larger). I've read through the general GD and upload stuff but can't get my head around where the functions would sit....I've got this in TreeImage.php (TreeImages are pictures of trees:)

    class TreeImage extends DataObject
    {
       static $db = array (
          'TreeImageCaption' => 'Text',
          
       );
       
       static $has_one = array (
          'TreeImageFile' => 'Image',
          'TreePage' => 'TreePage'
       );
       

       public function getCMSFields_forPopup()
       {
          return new FieldSet(
             new TextField('TreeImageCaption'),
             new ImageField('TreeImageFile')
          );
       }
    }

    so, I want to do something like:

    function generateTreeThumb($gd) {
    $gd->setQuality(100);
    return $gd->croppedResize(240,180);
    }

    function generateTreeLarger($gd) {
    $gd->setQuality(100);
    return $gd->croppedResize(600,450);
    }

    but I'm not sure where it should sit....any helpful hints?? cheers

  • Breastfed
    Avatar
    Community Member
    44 Posts

    Re: Preview: DataObjectManager module Link to this post

    Hello

    yesterday i installed the DataObjectManager.
    BUt the Drag and Drop Function doesn't work.

    And second Question.
    I Have a Tablefield "Status" which is defined by 0 (offline) or 1 (online).
    Now i have the Table with Status on top but with 1 or nothing in the fields.
    How can i set online and offline there?

    My current Code:
    [bold]
       function getCMSFields() {
          $fields = parent::getCMSFields();
          
          //related links tab   
          $manager = new DataObjectManager(
             $this,
             'LocationSubmissions',
             'LocationSubmission',
             array('Name' => 'Name','PLZ'=>'PLZ', 'Location' => 'Ort', 'Status' => 'Status'),
             'getCMSFields_forPopup'
          );
          
          $manager->setFilter('Status','Nach Status sortieren',array(
             '1' => 'online',
             '0' => 'offline'
          ));
          
          $fields->addFieldtoTab("Root.Content.Locationsubmission",$manager);
          return $fields;

       }

    [/bold]

    Thanky you all!

  • drye
    Avatar
    Community Member
    49 Posts

    Re: Preview: DataObjectManager module Link to this post

    @Breastfed: in your mysite/_config.php add the line:

    SortableDataObject::add_sortable_class('LocationSubmission');

    That will get the drag and drop sorting working.

    As for the status, EDIT...
    Add this code to your LocationSubmission

    public function getStatusField()
       {
          $value = $this->Status;
          if($value) return "Online";
          else return "Offline";
       }


    EDIT #2
    Also, add to your manager:

    $manager = new DataObjectManager(
    $this,
    'LocationSubmissions',
    'LocationSubmission',
    array('Name' => 'Name','PLZ'=>'PLZ', 'Location' => 'Ort', 'Status''getStatusField' => 'Status'),
    'getCMSFields_forPopup'
    );

  • drye
    Avatar
    Community Member
    49 Posts

    Re: Preview: DataObjectManager module Link to this post

    UncleCheese: Is there a way to make the upload directory be assets/[pagename]

    I see that you can let the user specify the directory, but I want to force it to be a sub directory of assets based on the name of the page.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Preview: DataObjectManager module Link to this post

    @ drye -- Thank you for pitching in on support. It's nice to have gotten to a point with this thing where the whole thing isn't just on my shoulders anymore. To change the upload folder, use the allowUploadFolderSelection() method.

    A reminder to everyone -- there is extensive documentation on DataObjectManager and all of its counterparts in the SS wiki. Please refer your questions there before simply saying something nondescript like "it doesn't work." I get dozens of support questions and feature requests every day, and it's very time consuming to go back and forth trying to get details. It is my goal to get this thing rock-solid and bug-free, so I appreciate any bug reports, but just make sure you all are doing your part and being as specific as possible and checking the documentation first.

    Thanks for understanding.

  • Ben Gribaudo
    Avatar
    Community Member
    181 Posts

    Re: Preview: DataObjectManager module Link to this post

    We really appreciate the modules you've authored and the quality of support you give, Uncle Cheese. Thank you.

    58358 Views
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
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.