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

Drag and Drop Sorting Won't Stick - DOM


Go to End
Reply


9 Posts   2572 Views

Avatar
theoldlr

Community Member, 103 Posts

16 December 2010 at 9:27am

Edited: 16/12/2010 9:29am

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

Avatar
theoldlr

Community Member, 103 Posts

21 December 2010 at 7:06am

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?

Avatar
UncleCheese

4085 Posts

21 December 2010 at 7:15am

Is the SortOrder field changing after you reorder them?

Avatar
theoldlr

Community Member, 103 Posts

21 December 2010 at 7:44am

No, the SortOrder values are not changing. Thanks!

Avatar
UncleCheese

4085 Posts

21 December 2010 at 9:18am

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.

Avatar
theoldlr

Community Member, 103 Posts

21 December 2010 at 10:10am

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

Avatar
UncleCheese

4085 Posts

21 December 2010 at 11:07am

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.

Avatar
theoldlr

Community Member, 103 Posts

22 December 2010 at 4:41am

Edited: 22/12/2010 9:38am

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?

Go to Top