Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Drag and Drop Sorting Won't Stick - DOM

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2
Go to End
Author Topic: 2355 Views
  • theoldlr
    Avatar
    Community Member
    103 Posts

    Drag and Drop Sorting Won't Stick - DOM Link to this post

    With the following code I can enable D&D sorting in the DOM, but after a save and publish all the items are back where they were:

    $datamanager = new DataObjectManager(
    $this, // Controller
    'CoverFlows', // Source name
    'CoverFlow', // Source class
    array(
    'Thumbnail' => 'Photo',
    'Description' => 'Description',
    'LinkToName' => 'LinksTo',
    'Width' => 'Width',
    'Height' => 'Height'
    ), // Headings
    'getCMSFields_forPopup'// Detail fields (function name or FieldSet object)
    // Filter clause
    // Sort clause
    // Join clause
    );


    class CoverFlow extends DataObject {

    static $db = array (
    'Description' => 'Varchar(255)',
    'Width' => 'Text',
    'Height' => 'Text',
    'LinkToName' => 'Varchar(255)'
    );

    static $has_one = array(
    'CoverFlowPage' => 'Page',
    'LinkTo' => 'SiteTree',
    'Photo' => 'Image'
    );

    public function getCMSFields_forPopup(){

    $imageUploadField = new ImageUploadField(
    'Photo',
    'Photo to add:',
    array(
    'buttonText' => 'Upload an Image'
    )
    );

    $imageUploadField->setuploadFolder('Images');
    $imageUploadField->allowFolderSelection = false;
    $siteTreeDropdown = new SimpleTreeDropdownField('LinkToID','Page to link to:','SiteTree');
    $siteTreeDropdown->setEmptyString(_t('Mysite.PLEASESELECT','Please select'));
    return new FieldSet(
    $imageUploadField,
    new TextField('Description','Description (appears with the image on page):'),
    $siteTreeDropdown//,
    //new TextField('Width'),
    //new TextField('Height')
    );

    }

    function Thumbnail() {
    $Photo = $this->Photo();
    if ( $Photo ) {
    return $Photo->CMSThumbnail();
    } else {
    return null;
    }
    }

    public function onBeforeWrite(){

    if($this->Photo()){
    $this->Width = $this->Photo()->getWidth();
    $this->Height = $this->Photo()->getHeight();
    if($this->LinkToID != null){
    $this->LinkToName = DataObject::get_by_id('SiteTree', $this->LinkToID)->Title;
    }
    parent::onBeforeWrite();
    }

    }

    public function ImagesLink(){
    return DataObject::get_by_id('SiteTree',$this->LinkToID)->Link();
    }

    }

    _config.php:

    SortableDataObject::add_sortable_classes(array('CoverFlow'));

  • theoldlr
    Avatar
    Community Member
    103 Posts

    Re: Drag and Drop Sorting Won't Stick - DOM Link to this post

    I'm really not having any luck figuring this out... I also tried as a FileDOM and ImageDOM with the same results. Everything works but Drag and Drop reordering. Anyone see this before?

  • UncleCheese
    Avatar
    4085 Posts

    Re: Drag and Drop Sorting Won't Stick - DOM Link to this post

    Is the SortOrder field changing after you reorder them?

  • theoldlr
    Avatar
    Community Member
    103 Posts

    Re: Drag and Drop Sorting Won't Stick - DOM Link to this post

    No, the SortOrder values are not changing. Thanks!

  • UncleCheese
    Avatar
    4085 Posts

    Re: Drag and Drop Sorting Won't Stick - DOM Link to this post

    Is the server throwing a 200 response code after you reorder? Might be a 500 coming back, in which case, I would check the response and see what the error is.

  • theoldlr
    Avatar
    Community Member
    103 Posts

    Re: Drag and Drop Sorting Won't Stick - DOM Link to this post

    Uncle Cheese, I think this is what you were asking about... I loaded the page and did a bunch of drag and drop re-orders, but this doesn't mean much to me. Hopefully it means more to you.

    127.0.0.1 - - [20/Dec/2010:15:48:38 -0500] "GET /admin/EditForm/field/CoverFlows?ctf[CoverFlows][start]=0&ctf[CoverFlows][per_page]=10&ctf[CoverFlows][showall]=1&ctf[CoverFlows][sort]=SortOrder&ctf[CoverFlows][sort_dir]=&ctf[CoverFlows][search]=&ctf[CoverFlows][filter]=&ctf[CoverFlows][view]= HTTP/1.1" 200 15727
    127.0.0.1 - - [20/Dec/2010:15:48:43 -0500] "POST /DataObjectManager_Controller/dosort/CoverFlow/ HTTP/1.1" 500 1331
    127.0.0.1 - - [20/Dec/2010:15:50:52 -0500] "GET /cms/images/mainmenu/hover.gif HTTP/1.1" 304 -
    127.0.0.1 - - [20/Dec/2010:15:51:21 -0500] "POST /DataObjectManager_Controller/dosort/CoverFlow/ HTTP/1.1" 500 1331
    127.0.0.1 - - [20/Dec/2010:15:51:26 -0500] "POST /Security/ping HTTP/1.1" 200 1
    127.0.0.1 - - [20/Dec/2010:15:53:00 -0500] "POST /DataObjectManager_Controller/dosort/CoverFlow/ HTTP/1.1" 500 1331
    127.0.0.1 - - [20/Dec/2010:15:53:02 -0500] "POST /DataObjectManager_Controller/dosort/CoverFlow/ HTTP/1.1" 500 1331
    127.0.0.1 - - [20/Dec/2010:15:53:48 -0500] "POST /DataObjectManager_Controller/dosort/CoverFlow/ HTTP/1.1" 500 1331
    127.0.0.1 - - [20/Dec/2010:15:53:51 -0500] "POST /DataObjectManager_Controller/dosort/CoverFlow/ HTTP/1.1" 500 1331
    127.0.0.1 - - [20/Dec/2010:15:53:53 -0500] "POST /DataObjectManager_Controller/dosort/CoverFlow/ HTTP/1.1" 500 1331
    127.0.0.1 - - [20/Dec/2010:15:53:54 -0500] "POST /DataObjectManager_Controller/dosort/CoverFlow/ HTTP/1.1" 500 1331

  • UncleCheese
    Avatar
    4085 Posts

    Re: Drag and Drop Sorting Won't Stick - DOM Link to this post

    Yeah, you're getting 500 errors. Get the contents of that response and that should point you in the direction of the error. Make sure your site is in dev mode and that you have PHP error reporting on.

  • theoldlr
    Avatar
    Community Member
    103 Posts

    Re: Drag and Drop Sorting Won't Stick - DOM Link to this post

    I can't seem to get the details on these 500 errors. I checked httpd.conf and php.ini and every mention of error logging is on to the fullest degree, but there is no info in either the apache error.log or the vhost specific error log--I have no idea why. The site has been in dev mode the whole time--no onscreen errors either. Do I need to turn something on in SS additionally? Am I looking in the wrong place?

    2355 Views
Page: 1 2
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.