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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Question re Album Cover Images


Go to End


2 Posts   955 Views

Avatar
JonC

Community Member, 8 Posts

28 August 2011 at 1:41pm

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

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

<% end_control %>
</ul>

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 %>

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

<% end_control %>

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

What's the proper way to do this?

Avatar
UncleCheese

Forum Moderator, 4102 Posts

30 August 2011 at 6:52am

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. http://www.leftandmain.com