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

attn uncle cheese - dataObjectManager bug?


Reply

32 Posts   4411 Views

Avatar
UncleCheese

8 July 2009 at 2:45am 4085 Posts

Okay, now we're getting somewhere. Post your code for that entire page.. I don't need the dataobjects.. just the getCMSFields for your page.

Avatar
klikhier

8 July 2009 at 3:29am Community Member, 150 Posts

class DesignDetailsPage extends Page {

...

public function getCMSFields() {
$fields = parent::getCMSFields();

$fields->addFieldToTab("Root.Content.Main", new DropdownField(
'ResponsibleOffice',
'Responsible office',
singleton('DesignDetailsPage')->dbObject('ResponsibleOffice')->enumValues()
),'Content');

      $manager2 = new DataObjectManager(
         $this, // Controller
         'Characteristics', // Source name
         'Characteristic', // Source class
         array(
            'Label' => 'Label',
            'Value' => 'Value'
         ), // Headings
         'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
         // Filter clause
         // Sort clause
         // Join clause
      );

      $fields->addFieldToTab('Root.Content.Characteristics', $manager2);

$fields->addFieldToTab("Root.Content.Factsheet", new FileIFrameField('Download1','Factsheet'));
$fields->addFieldToTab("Root.Content.Design drawing", new FileIFrameField('Download2','Design drawing'));

      $manager3 = new DataObjectManager(
         $this, // Controller
         'References', // Source name
         'Reference', // Source class
         array(
            'Name' => 'Name',
            'Website' => 'Website',
            'Category' => 'Category'
         ), // Headings
         'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
         // Filter clause
         // Sort clause
         // Join clause
      );

      $fields->addFieldToTab('Root.Content.References', $manager3);

return $fields;
}   

AND this code from page.php (I have set up one ImageDOM in page.php that I use on alle pages). As I'm writing this... this solution might be a trouble maker...

class Page extends SiteTree {

...

public function getCMSFields() {
$fields = parent::getCMSFields();

if(!Member::currentUser()->isAdmin()) {

$fields->removeByName("Behaviour");
$fields->removeByName("To-do");
$fields->removeByName("Reports");
$fields->removeByName("Google Sitemap");
$fields->removeByName("Navigation label");
}

      $manager = new ImageDataObjectManager(
         $this, // Controller
         'Photos', // Source name
         'Photo', // Source class
         'Image',
         array(), // Headings
         'getCMSFields_forPopup' // Detail fields (function name or FieldSet object)
         // Filter clause
         // Sort clause
         // Join clause
      );

      $fields->addFieldToTab('Root.Content.Images', $manager);

$metadataTab = $fields->findOrMakeTab('Root.Content.Metadata');
$fields->removeByName('Metadata');
$fields->addFieldToTab('Root.Content', $metadataTab);

return $fields;
}   

Avatar
UncleCheese

8 July 2009 at 3:53am 4085 Posts

Can you check if activating drag-and-drop on the one that doesn't work actually enables drag-and-drop on one of the other two DOMs on the page?

Avatar
klikhier

8 July 2009 at 4:04am Community Member, 150 Posts

Selecting checkboxe drag'n'drop on Characteristics and/or References doesn't change anything. Cursor changes into a hand, but when trying to drag only text is selected. The ImageDOM drag'n'drop works fine after acitvating drag'n'drop. I can't see any cross-tab behaviour.

Avatar
UncleCheese

8 July 2009 at 4:12am 4085 Posts

Does it work when you remove the ImageDOM?

BTW, you're going to want a ->setParentClass('Page') on the ImageDOM if it's cascading down to subclasses. Otherwise it will barf when you pass it $this as a controller.

Avatar
klikhier

8 July 2009 at 7:20am Community Member, 150 Posts

Yes! When I comment out the ImageDOM in page.php, drag'n'drop works again for Characteristics and References!

Avatar
UncleCheese

8 July 2009 at 7:53am 4085 Posts

Alright, I'll try setting up concurrent instances of ImageDOM and DOM and see what happens.

Avatar
biapar

8 July 2009 at 10:07pm Forum Moderator, 435 Posts

Hi, I've the similar problem when I click on "Add Image" ( see this old post: http://www.silverstripe.org/archive/show/212710#post212710 ) , I've on PopUp Windows this error: "I can't handle sub-URLs of a CMSMain object."

class ImageAttachment extends DataObject {
static $db = array(
'Name' => 'Text'
);
static $has_one = array(
'Image' => 'Resize_Image',
'Product' => 'Product'
);

static $field_names = array('Name' => 'Name');

function getCMSFields_forPopup() {
$fields = new FieldSet();
$fields->push(new TextField('Name', 'Name'));
$fields->push(new ImageField('Image', 'Image'));

return $fields;
}

}

....
$imagetable = new ComplexTableField(
$this,
'ImageAttachments', // relation name
'ImageAttachment', // object class
ImageAttachment::$field_names, // fields to show in table
ImageAttachment::getCMSFields_forPopup(), // form that pops up for edit
"ProductID = {$this->ID}", // a filter to only display item associated with this page
"Name ASC" // Sort by name
);

$fields->addFieldToTab('Root.Content.Additional Images', $imagetable);