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

Question re Album Cover Images


2 Posts   674 Views


28 August 2011 at 1:41pm Community Member, 8 Posts

Hi, all. I'm a newbie to SS, and am having some difficulty working with image_gallery.

I'm trying to cause a page to display an album's cover art as well as all the images in the album in a list of thumbnails, with clicking on the cover art or any of the thumbnails bringing up a shadowbox via shadowbox.js. I am able to access the thumbnails, but not the album's cover art.

Code below:

HTML code, using a page that extends ImageGalleryPage.php

<% control GalleryItems %>
<li><a href="$Image.URL" rel="shadowbox[gallery]">$Image.CroppedImage(100,60)</a></li>

<% end_control %>

This code displays a nice list of everything in the album, but I also need the cover art. I attempted to get access to the album cover art this way:

<% control Albums %>

<% control FormattedCoverImage %>
<a href="$Image.URL" rel=" ">$Image.CroppedImage(300,200)</a>
<% end_control %>

<% control GalleryItems %>
<li><a href="$Image.URL" rel="shadowbox">$Image.CroppedImage(100,60)</a></li>
<% end_control %>

<% end_control %>

Nothing displays from the first control, but the second control continues to work.

What's the proper way to do this?


30 August 2011 at 6:52am 4085 Posts

FormattedCoverImage() returns an Image object, so you don't need to traverse to to $URL like that. It's already in scope.

GalleryItems, on the other hand, returns ImageGalleryItem objects, which have a relation to an Image, so you need to traverse to it..

Silverstripe tips, tutorials, screencasts, and more.