Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Issue with ImageGallery $RecentImagesGallery

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 1193 Views
  • edk
    Avatar
    Community Member
    39 Posts

    Issue with ImageGallery $RecentImagesGallery Link to this post

    I have been trying to figure this one out but to no avail. I want to pass two parameters in the RecentImagesGallery function. Example on a template page I would call $RecentImagesGallery(12,team-gallery).

    I continue to get SQL syntax errors in DEV mode. I am running SS2.3.3, and have tried altering things in the class ImageGallerySiteTree to track the issue. No luck.

    Here is the error output from DEV:
    #########################
    [User Error] Couldn't run query: SELECT `ImageGalleryItem`.*, `ImageGalleryItem`.ID, if(`ImageGalleryItem`.ClassName,`ImageGalleryItem`.ClassName,'ImageGalleryItem') AS RecordClassName FROM `ImageGalleryItem` WHERE (ImageGalleryPageID = ) ORDER BY Created DESC LIMIT 12 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 ') ORDER BY Created DESC LIMIT 12' at line 1
    #########################

    Any assitiance would be greatly appreciated.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Issue with ImageGallery $RecentImagesGallery Link to this post

    In ImageGallerySiteTree.php, look at this function:

       function RecentImages($count = 5, $url_segment = null)
       {
          $gallery = $this->getGalleryFor($url_segment);
          if($gallery) {
             $items = DataObject::get("ImageGalleryItem","ImageGalleryPageID = {$gallery->ID}","Created DESC",null,$count);

    You'll see that $gallery is obviously coming back as an object because you're not getting a non-object error, but for whatever reason it doesn't have an ID. Can you see what the getGalleryFor() is returning? Something's screwy.

  • Thomashv
    Avatar
    Community Member
    32 Posts

    Re: Issue with ImageGallery $RecentImagesGallery Link to this post

    Hi guys!

    Did you sort out this problem? I get a similar error... The function works when I just call $RecentImagesGallery(5), but when I insert a URLSegment I get following mySql error:

    [User Error] Couldn't run query: SELECT "ImageGalleryItem"."ClassName", "ImageGalleryItem"."Created", "ImageGalleryItem"."LastEdited", "ImageGalleryItem"."Caption", "ImageGalleryItem"."SortOrder", "ImageGalleryItem"."ImageGalleryPageID", "ImageGalleryItem"."AlbumID", "ImageGalleryItem"."ImageID", "ImageGalleryItem"."ID", CASE WHEN "ImageGalleryItem"."ClassName" IS NOT NULL THEN "ImageGalleryItem"."ClassName" ELSE 'ImageGalleryItem' END AS "RecordClassName" FROM "ImageGalleryItem" WHERE (ImageGalleryPageID = ) ORDER BY Created DESC LIMIT 5 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 ') ORDER BY Created DESC LIMIT 5' at line 1

  • UncleCheese
    Avatar
    4085 Posts

    Re: Issue with ImageGallery $RecentImagesGallery Link to this post

    I think I see the problem. Line 8 of ImageGallerySiteTree.php uses get() instead of get_one();

    return ($url_segment === null) ? DataObject::get_one("ImageGalleryPage") : DataObject::get_one("ImageGalleryPage","URLSegment='$url_segment'");

    That's fixed in the latest rev.

  • Thomashv
    Avatar
    Community Member
    32 Posts

    Re: Issue with ImageGallery $RecentImagesGallery Link to this post

    Thank you very much UncleCheese!
    That did the trick!

    And thank you for the great modules you have developed!

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