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

Preview: DataObjectManager module


Go to End
Reply


379 Posts   63607 Views

Avatar
robinp

Community Member, 33 Posts

24 March 2009 at 3:13pm

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

Avatar
UncleCheese

Forum Moderator, 4096 Posts

24 March 2009 at 3:52pm

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.

Avatar
NickJacobs

Community Member, 144 Posts

24 March 2009 at 6:45pm

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

Avatar
Breastfed

Community Member, 44 Posts

24 March 2009 at 7:46pm

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!

Avatar
drye

Community Member, 49 Posts

24 March 2009 at 9:29pm

Edited: 24/03/2009 11:41pm

@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'
);

Avatar
drye

Community Member, 49 Posts

24 March 2009 at 10:32pm

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.

Avatar
UncleCheese

Forum Moderator, 4096 Posts

25 March 2009 at 3:15am

Edited: 25/03/2009 3:17am

@ 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.

Avatar
Ben Gribaudo

Community Member, 181 Posts

25 March 2009 at 6:46am

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

Go to Top