Hallo guys,
I´ve using the ImageDataObjectManager (for Silverstripe 2.4.6.) to upload images and it doesn´t work fine.
For this I use the latest version of Uploadify.
If I click on "Upload files", select an image and upload the image, the file is shown in the upload-window,
but disappear after upload is finish and Silverstripe said "no files found". So I don´t get the window, where I can select and import the image.
Anyway, the image was wel uploaded in the assets and I can select it with the option "Choose existing".
After I´ve uploaded the image I get an error (via email):
Error: Couldn't run query: SELECT "File"."ClassName", "File"."Created", "File"."LastEdited", "File"."Name", "File"."Title", "File"."Filename", "File"."Content", "File"."Sort", "File"."ShowInSearch", "File"."SortOrder", "File"."ParentID", "File"."OwnerID", "File"."ID", CASE WHEN "File"."ClassName" IS NOT NULL THEN "File"."ClassName" ELSE 'File' END AS "RecordClassName" FROM "File" WHERE ("File"."ID" IN (\n323)) ORDER BY "SortOrder" ASC You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\n323)) ORDER BY "SortOrder" ASC' at line 1
At line 525 in /var/www/web211/html/sapphire/core/model/MySQLDatabase.php
user_error(Couldn't run query: SELECT "File"."ClassName", "File"."Created", "File"."LastEdited", "File"."Name", "File"."Title", "File"."Filename", "File"."Content", "File"."Sort", "File"."ShowInSearch", "File"."SortOrder", "File"."ParentID", "File"."OwnerID", "File"."ID", CASE WHEN "File"."ClassName" IS NOT NULL THEN "File"."ClassName" ELSE 'File' END AS "RecordClassName" FROM "File" WHERE ("File"."ID" IN (\n323)) ORDER BY "SortOrder" ASC You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\n323)) ORDER BY "SortOrder" ASC' at line 1,256) line 525 of MySQLDatabase.php MySQLDatabase->databaseError(Couldn't run query: SELECT "File"."ClassName", "File"."Created", "File"."LastEdited", "File"."Name", "File"."Title", "File"."Filename", "File"."Content", "File"."Sort", "File"."ShowInSearch", "File"."SortOrder", "File"."ParentID", "File"."OwnerID", "File"."ID", CASE WHEN "File"."ClassName" IS NOT NULL THEN "File"."ClassName" ELSE 'File' END AS "RecordClassName" FROM "File" WHERE ("File"."ID" IN (\n323)) ORDER BY "SortOrder" ASC | You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\n323)) ORDER BY "SortOrder" ASC' at line 1,256) line 123 of MySQLDatabase.php MySQLDatabase->query(SELECT "File"."ClassName", "File"."Created", "File"."LastEdited", "File"."Name", "File"."Title", "File"."Filename", "File"."Content", "File"."Sort", "File"."ShowInSearch", "File"."SortOrder", "File"."ParentID", "File"."OwnerID", "File"."ID", CASE WHEN "File"."ClassName" IS NOT NULL THEN "File"."ClassName" ELSE 'File' END AS "RecordClassName" FROM "File" WHERE ("File"."ID" IN (\n323)) ORDER BY "SortOrder" ASC,256) line 129 of DB.php DB::query(SELECT "File"."ClassName", "File"."Created", "File"."LastEdited", "File"."Name", "File"."Title", "File"."Filename", "File"."Content", "File"."Sort", "File"."ShowInSearch", "File"."SortOrder", "File"."ParentID", "File"."OwnerID", "File"."ID", CASE WHEN "File"."ClassName" IS NOT NULL THEN "File"."ClassName" ELSE 'File' END AS "RecordClassName" FROM "File" WHERE ("File"."ID" IN (\n323)) ORDER BY "SortOrder" ASC,256) line 404 of SQLQuery.php SQLQuery->execute() line 761 of File.php File->instance_get("File"."ID" IN (\n323),,,,DataObjectSet) line 2714 of DataObject.php DataObject::get(File,"File"."ID" IN (\n323)) line 161 of MultipleFileUploadField.php MultipleFileUploadField->Files() line 369 of ViewableData.php ViewableData->obj(Files,,,1,) line 411 of ViewableData.php ViewableData->cachedCall(Files,) line 424 of ViewableData.php ViewableData->hasValue(Files) line 12 of .cache.uploadify.templates.Includes.AttachedFiles.ss include(/var/www/web211/html/silverstripe-cache/.cache.uploadify.templates.Includes.AttachedFiles.ss) line 429 of SSViewer.php SSViewer->process(MultipleImageUploadField) line 342 of ViewableData.php ViewableData->renderWith(AttachedFiles) line 107 of MultipleFileUploadField.php MultipleFileUploadField->refresh(SS_HTTPRequest) line 143 of RequestHandler.php RequestHandler->handleRequest(SS_HTTPRequest) line 161 of RequestHandler.php RequestHandler->handleRequest(SS_HTTPRequest) line 161 of RequestHandler.php RequestHandler->handleRequest(SS_HTTPRequest) line 161 of RequestHandler.php RequestHandler->handleRequest(SS_HTTPRequest) line 161 of RequestHandler.php RequestHandler->handleRequest(SS_HTTPRequest) line 147 of Controller.php Controller->handleRequest(SS_HTTPRequest) line 282 of Director.php Director::handleRequest(SS_HTTPRequest,Session) line 125 of Director.php Director::direct(/admin/EditForm/field/Images/UploadifyForm/field/UploadedFiles/refresh) line 127 of main.php
In my opinion there is anywhere an syntax error nearby "sortorder".
Here is my code:
<?php
// /mysite/code/GalleryPage.php
class GalleryPage extends Page
{
static $has_many = array (
'Images' => 'ImageResource'
);
public static $db = array(
);
public static $has_one = array(
);
public function getCMSFields()
{
$f = parent::getCMSFields();
$manager = new ImageDataObjectManager(
$this, // Controller
'Images', // Source name
'ImageResource', // Source class
'Attachment', // File name on DataObject
array(
'Title' => 'Title',
'Caption' => 'Caption'
)
);
$f->addFieldToTab("Root.Content.Main",$manager);
$f->removeFieldFromTab("Root.Content.Main","Content");
return $f;
}
}
class GalleryPage_Controller extends Page_Controller {
function init() {
parent::init();
//Include fancybox Code
Requirements::javascript('themes/tsg-nordhorn/js/jquery.js');
Requirements::javascript('themes/tsg-nordhorn/fancybox/jquery.mousewheel-3.0.4.pack.js');
Requirements::javascript('themes/tsg-nordhorn/fancybox/jquery.fancybox-1.3.4.pack.js');
Requirements::javascript('themes/tsg-nordhorn/js/fancybox.js');
Requirements::javascript('themes/tsg-nordhorn/js/gallery.js');
Requirements::insertHeadTags("<style type='text/css'>@import url(themes/" . SSViewer::current_theme() . "/fancybox/jquery.fancybox-1.3.4.css);</style>");/*fancybox*/
}
}
<?php
// /mysite/code/ImageResource.php
class ImageResource extends DataObject
{
static $db = array (
'Title' => 'Text',
'Caption' => 'Text'
);
static $has_one = array (
'Attachment' => 'Image', //Needs to be an image
'GalleryPage' => 'GalleryPage',
'PressePage' => 'PressePage'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Title'),
new TextareaField('Caption'),
new FileIFrameField('Attachment')
);
}
}
?>
Does anyone (UncleCheese maybe) see an mistake? I can´t figure it out.
I am very thankful, if somebody could help me. It really freaks me out.
Thx,
Bereusei