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.

Widgets /

Discuss SilverStripe Widgets.

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

Modifying Gallery Widget : Latest Galleries


Go to End


1569 Views

Avatar
Fraser

Community Member, 48 Posts

14 June 2012 at 1:51pm

Another query about some modifications to the gallery widget..

I need to be able to pull out an image (doesn't matter which) from one of the listed galleries.

function Galleries() {
	  	$nrtoshow = (0<$this->NumberToShow) ? "0,".$this->NumberToShow : "";
    	$galleries = DataObject::get(
    		"Page",
    		"SiteTree_Live.ClassName = 'GalleryPage' AND ShowInMenus = 1",
    		"LastEdited DESC",
    		"",
    		"$nrtoshow"
    	);
    	
		return $galleries;
	}

I tried adding a join:

LEFT JOIN GalleryPage ON SiteTree_Live.ID = GalleryPage.ID LEFT JOIN File ON (GalleryPage.FolderID = File.ParentID  AND File.ClassName='Image')

but because it is a page object am unable to output an Image object. Is there a way I can do this?