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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Issue with ImageGallery $RecentImagesGallery


Go to End


5 Posts   1631 Views

Avatar
edk

Community Member, 39 Posts

23 September 2009 at 6:16pm

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.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

24 September 2009 at 7:28am

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.

Avatar
Thomashv

Community Member, 35 Posts

26 June 2010 at 1:13am

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

Avatar
UncleCheese

Forum Moderator, 4102 Posts

26 June 2010 at 1:43am

Edited: 26/06/2010 1:44am

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.

Avatar
Thomashv

Community Member, 35 Posts

28 June 2010 at 11:10pm

Thank you very much UncleCheese!
That did the trick!

And thank you for the great modules you have developed!