Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Showing all images from all albums on one page?

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: 1290 Views
  • Jacknife
    Avatar
    Community Member
    16 Posts

    Showing all images from all albums on one page? Link to this post

    Hi all,

    I am pretty new to SS and have got the ImageGallery set up OK. I need to be able to show all the images in the gallery on the entry page to the gallery and then have the individual albums selectable from a sub menu (which is working fine).

    Any ideas how I might do this?

    Ta

  • UncleCheese
    Avatar
    4085 Posts

    Re: Showing all images from all albums on one page? Link to this post

    Not sure I get it. So the main gallery view is every image in the gallery, and the album links filter them down?

  • Jacknife
    Avatar
    Community Member
    16 Posts

    Re: Showing all images from all albums on one page? Link to this post

    Exactly! That is what my client wants.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Showing all images from all albums on one page? Link to this post

    Hmm.. Right now you can't do it without extending the class, because all the queries are album dependent. If no current album is found, they return null. I'm wondering if it is worth adding a function that would return all images regardless of the album.

    In any event, for now, you can just subclass ImageGalleryPage.php to something like MyImageGalleryPage and create a controller function like:

    function AllImages()
    {
    return $this->getComponents('GalleryItems');
    }

    then create /mysite/templates/Includes/AlbumList.ss and do your <% control AllImages %> in there. That's probably the quickest solution.

    Post your code if you get stuck.

  • Jacknife
    Avatar
    Community Member
    16 Posts

    Re: Showing all images from all albums on one page? Link to this post

    Sorry I have no idea where to even start on this I am very new to Silverstripe.

    Cheers

  • UncleCheese
    Avatar
    4085 Posts

    Re: Showing all images from all albums on one page? Link to this post

    I've decided this is probably something that the module should be able to do without any customization. You can now view images without the context of an album.

    So, to achieve what you're looking for, first, run an SVN update to get the new code. Then you can create a custom AlbumList.ss. Copy the contents from image_gallery/templates/Includes/AlbumList.ss into mysite/templates/Includes/AlbumList.ss

    Add this where you want the images to display:

    <ul class="gallery-layout">
    <% control GalleryItems %>
          <li style="height:{$Top.ThumbnailSize}px;width:{$Top.ThumbnailSize}px;">
                <a id="ViewLink-$ID" rel="$RelAttr" class="$ClassAttr" title="$Caption" href="$ViewLink"><img src="$ThumbnailURL" alt="$Title"/></a>
          </li>
    <% end_control %>

    Worked in my testing.

    1290 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.