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.

Archive /

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

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

Albums in Gallery


Go to End


30 Posts   8337 Views

Avatar
sonicparke

74 Posts

22 July 2008 at 10:38am

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?

Avatar
Willr

Forum Moderator, 5523 Posts

22 July 2008 at 1:47pm

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

Avatar
Carbon Crayon

Community Member, 598 Posts

14 November 2008 at 12:59pm

Edited: 14/11/2008 12:59pm

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

Avatar
deejayh

Community Member, 10 Posts

15 November 2008 at 3:17am

Edited: 20/11/2008 10:57pm

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

Avatar
Carbon Crayon

Community Member, 598 Posts

15 November 2008 at 5:00am

Edited: 15/11/2008 5:01am

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?

Avatar
Carbon Crayon

Community Member, 598 Posts

15 November 2008 at 1:08pm

Edited: 15/11/2008 1:26pm

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 :D

Avatar
mhull

Community Member, 79 Posts

20 November 2008 at 8:28am

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?

Avatar
deejayh

Community Member, 10 Posts

20 November 2008 at 10:59pm

Yep I tried without success.

Could you attach the files here Aram?

Dave

Go to Top