Jump to:

7921 Posts in 1359 Topics by 933 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Bug Reports

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., 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
Go to End
Author Topic: 38531 Views
  • UncleCheese
    Avatar
    4085 Posts

    Re: Bug Reports Link to this post

    Thank you!!

    --------------------
    SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

  • MarcusDalgren
    Avatar
    Community Member
    287 Posts

    Re: Bug Reports Link to this post

    DataObjectManager->setSourceId() has no effect since the sourceID() function never checks for or returns the value.
    Change the sourceID() function from

       function sourceID() {
          if($this->isNested)
             return $this->controller->ID;            
          $idField = $this->form->dataFieldByName('ID');
          return ($idField && is_numeric($idField->Value())) ? $idField->Value() : (isset($_REQUEST['ctf']['ID']) ? $_REQUEST['ctf']['ID'] : null);
       }

    to

       function sourceID() {
          if (isset($this->sourceID) && is_numeric($this->sourceID)) {
             return $this->sourceID;
          }
          if($this->isNested)
             return $this->controller->ID;            
          $idField = $this->form->dataFieldByName('ID');
          return ($idField && is_numeric($idField->Value())) ? $idField->Value() : (isset($_REQUEST['ctf']['ID']) ? $_REQUEST['ctf']['ID'] : null);
       }

    This way the custom source ID will be returned if it's been set.

  • swaiba
    Avatar
    Forum Moderator
    1689 Posts

    Re: Bug Reports Link to this post

    I notice this when I tried to use the Has One DOM....

    casted summary fields throw a SQL error...

       public static $summary_fields = array (
          'CastedText'=>'NewTitle',
       );

       static $casting = array( "CastedText" => "Text" );
       public function CastedText() {
          return $this->NormalDBField.' - text';
       }

  • Pike
    Avatar
    Community Member
    39 Posts

    Re: Bug Reports Link to this post

    I then, you'd change in DataObjectManager.php line 500, this code:

    Before:

    new LabelField('show', _t('DataObjectManager.PERPAGESHOW','Show').' '),
    new DropdownField('PerPage','',$map, $value),
    new LabelField('results', ' '._t('DataObjectManager.PERPAGERESULTS','results per page'))

    After:

    new LabelField('show', _t('DataObjectManager.PERPAGESHOW','Show').' ',null,true),
    new DropdownField('PerPage','',$map, $value),
    new LabelField('results', ' '._t('DataObjectManager.PERPAGERESULTS','results per page'),null,true)

    Reason: I sent translation fo cs_CZ and sk_SK. After changes I see string correctly. I cannot send files (images) to be more see-able.

  • MarijnKampf
    Avatar
    Community Member
    151 Posts

    Re: Bug Reports Link to this post

    I'm using Uploadify/DOM 521 and I'm running into an issue with using the same image for multiple purposes. It could be this is a limitation of the SS file system rather than Uploadify/DOM.

    My setup: I've added a Thumbnail Image to the page class, and I'm using DOM + Uploadify to add a list of files (Downloads) to an Example. Multiple examples are displayed on a single page using the Examples page type. The Downloads / Example classes are based on the code provided on the Uploadify documentation page.

    The issue I have is on adding an image as the thumbnail of a page, and then adding the same image as an Example download the Thumbnail disappears from the page. I believe this is due to the fact that the ClassName in the File table is changed from Image to Download.

    Is there a way that allows multiple uses of the same file still using DOM+Uploadify?

    I've included trimmed down test code below.

    mysite/code/Page.php

    <?php
    class Page extends SiteTree {
       public static $has_one = array(
    'Thumbnail' => 'Image',
       );

       function getCMSFields() {
          $fields = parent::getCMSFields();
    $fields->addFieldToTab("Root.Content.Thumbnail", new FileUploadField('Thumbnail', 'Thumbnail'));
          return $fields;
       }

    }

    class Page_Controller extends ContentController {

    }

    mysite/code/Examples.php

    <?php
    class Examples extends Page {
       static $has_many = array (
          'Examples' => 'Example'
       );

       public function getCMSFields() {
          $fields = parent::getCMSFields();
          $fields->addFieldToTab("Root.Content.Examples", new DataObjectManager(
             $this,
             'Examples',
             'Example',
             array('Title' => 'Title', 'Description' => 'Description'),
             'getCMSFields_forPopup'
          ));

          return $fields;
       }
    }

    class Examples_Controller extends Page_Controller {

    }

    mysite/code/Example.php

    <?php
    class Example extends DataObject {
       static $db = array (
          'Title' => 'Text',
          'Description' => 'HTMLText'
       );
       static $has_one = array (
          'ExamplesPage' => 'Examples',
          'Thumbnail' => 'Image'
       );
       static $has_many = array (
          'Downloads' => 'Download'
       );

       public function getCMSFields() {
          $fields = parent::getCMSFields();
          $fields->addFieldToTab("Root.Content.Downloads", new MultipleFileUploadField('Downloads','Select downloads'));
          return $fields;
       }

       public function getCMSFields_forPopup() {
          $fields = new FieldSet(
             new TextField('Title','Title'),
             new SimpleHTMLEditorField('Description','Description'),
             new ImageUploadField('Thumbnail','Thumbnail'),
             new MultipleFileUploadField('Downloads','Select download files')
          );
          return $fields;
       }

    }

    mysite/code/Download.php

    <?php
    class Download extends File {
       static $has_one = array(
          'Example' => 'Example'
       );
    }

  • UncleCheese
    Avatar
    4085 Posts

    Re: Bug Reports Link to this post

    You're using the "choose existing" tab to do that? I think that's going to give you trouble because the classnames are different. You're going to have to upload the same file twice..

    ---------------
    Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com

  • MarijnKampf
    Avatar
    Community Member
    151 Posts

    Re: Bug Reports Link to this post

    That's what I feared, as I suggested uploading the same file twice as a workaround to the user, but I do feel that's a bit counter intuitive. Is there a way to use the same file? Or alternatively limit the assets sub folder that can be selected (to force the user to upload the file again...)

  • UncleCheese
    Avatar
    4085 Posts

    Re: Bug Reports Link to this post

    Well, what you're describing doesn't make a whole lot of sense. I know for the user it's weird, but if you think about it, you're asking that a single file have two different ClassName fields simultaneously. That's just not going to work.

    Is the thumbnail always the same as the other upload? You could just get rid of that field all together and assign the ThumbnailID on write..

    ---------------
    Silverstripe tips, tutorials, screencasts, and more. http://www.leftandmain.com

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