Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Albums in Gallery

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

Page: 1 2 3 4
Go to End
Author Topic: 5618 Views
  • sonicparke
    Avatar
    74 Posts

    Albums in Gallery Link to this post

    I seem to be having trouble finding the "easy" way to create albums in Gallery 0.2.2. Is there an easy way or will I have to create a new page type & so forth?

  • Willr
    Avatar
    Forum Moderator
    5464 Posts

    Re: Albums in Gallery Link to this post

    The gallery does not support albums as far as Im aware but this would be an awesome feature if you can contribute! I think what most people do - or what ive done in the past is make a GalleryHolder.php which has GalleryPage - Albums and that galleryholder just lists all the albums etc..

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Albums in Gallery Link to this post

    Hi Willr

    how do you create a GalleryHolder and get it to return the images from its galleryPage children?

    I can't seem to figure out how to return a group of dataObjectSets to display in the template. I'm no SS pro so I may be approaching this in the wrong way; I'm pretty much using the same method as the LatestArticles function in tutorial 2 and calling CurrentGalleryItems for each of the child pages, but I can't figure out how to make a group or array of these dataObjectSets to return to the template?.....:S

  • deejayh
    Avatar
    Community Member
    10 Posts

    Re: Albums in Gallery Link to this post

    This would be a great addition to Gallery.

    Aram, you seem to have the right idea, but with my simple capabilities I could not help you.

    At the moment, I have a gallery HOLDING page, with various images, with each one linked directly to each album. Simple - but not ideal.

    Regards,
    Dave

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Albums in Gallery Link to this post

    ahhhh, I think maybe that's what willr meant too, he just lists links the the albums rather than displays any of the photos within them.

    I can display the first page of images by hard coding the gallery names into the template doing the following
    GalleryHolder.php

    function getGalleryItems($gallery){
    $galleryPage = DataObject::get_one("GalleryPage", "Title = $gallery");
    return $galleryPage.CurrentGalleryItems();
    }


    GalleryHolder.ss

    <% control getGalleryItems(gallery1) %>

    themplate stuff

    <% end control %>
    <% control getGalleryItems(gallery2) %>

    themplate stuff

    <% end control %>
    etc....

    but thats as far as I've got and it's not great because it won't dynamically add child galleries to the holder and will break if you change the names of the existing galleries.......

    does anyone know if it's even possible to make an array of dataObjectSets or to somehow return a group of them that the template can iterate over?

  • Aram
    Avatar
    Community Member
    598 Posts

    Re: Albums in Gallery Link to this post

    Ok, so this is actually really easy!

    All you have to do to get the first page of pictures from each child gallery is put the following into GalleryHolder.ss

    <% control children %>
    <a href="$Link">$Title</a>
    <% control CurrentGalleryItems %>

    <!-- Template stuff, copied from GalleryPageContent.ss to display the images -->

    <% end_control %>
    <a href="$Link">go to gallery &gt;&gt;</a>
    <% end_control %>

    Thats it! You get a nice set of pictures from each child galleries first page and its title.

    can't believe how complicated I had made this, didn't even need any extra controller code! (EDIT: you need to copy the init function from GalleryPage.php so it gets the lightbox code/css etc)

    I guess it shows how much I've still got to learn and also how damn awsome SS is

  • mhull
    Avatar
    Community Member
    79 Posts

    Re: Albums in Gallery Link to this post

    How would you get the Gallery to display albums?

    I tried following the instructions above by aram, but couldn't get it to work.
    Do you have any more info? or could you make the files available?

  • deejayh
    Avatar
    Community Member
    10 Posts

    Re: Albums in Gallery Link to this post

    Yep I tried without success.

    Could you attach the files here Aram?

    Dave

    5618 Views
Page: 1 2 3 4
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.