Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » attn uncle cheese - dataObjectManager bug?

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: 4092 Views
  • UncleCheese
    Avatar
    4085 Posts

    Re: attn uncle cheese - dataObjectManager bug? Link to this post

    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.

  • klikhier
    Avatar
    Community Member
    150 Posts

    Re: attn uncle cheese - dataObjectManager bug? Link to this post

    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;
    }   

  • UncleCheese
    Avatar
    4085 Posts

    Re: attn uncle cheese - dataObjectManager bug? Link to this post

    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?

  • klikhier
    Avatar
    Community Member
    150 Posts

    Re: attn uncle cheese - dataObjectManager bug? Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: attn uncle cheese - dataObjectManager bug? Link to this post

    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.

  • klikhier
    Avatar
    Community Member
    150 Posts

    Re: attn uncle cheese - dataObjectManager bug? Link to this post

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

  • UncleCheese
    Avatar
    4085 Posts

    Re: attn uncle cheese - dataObjectManager bug? Link to this post

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

  • biapar
    Avatar
    Forum Moderator
    435 Posts

    Re: attn uncle cheese - dataObjectManager bug? Link to this post

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

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