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.

All other Modules /

Discuss all other Modules here.

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

Including gallery items in a different page template


Go to End


5 Posts   2571 Views

Avatar
bird

Community Member, 9 Posts

27 November 2009 at 2:55pm

Edited: 03/12/2009 2:14am

Hi!

I would like to include gallery images / items from a specific gallery page in another page's template.
Using something like: <% control Page(mygallerypage) %>$Content<% end_control %> doesen't work because this can only be used for the static content / text but not for the dynamic gallery images.

How could I include those images in a different template anyway?

Best regards
bird

Avatar
patjnr

Community Member, 102 Posts

30 November 2009 at 8:27pm

A you trying to add more than 1 gallery pages on you site or you only want to use the images. ???

Avatar
bird

Community Member, 9 Posts

30 November 2009 at 8:56pm

Edited: 03/12/2009 2:15am

I would like to call those images in another template.
willr (my hero) gave me the code in the IRC channel. Maybe this might be helpful for other users, too:

Calling gallery page items in another template:

<% control Page(your_gallerypage) %>
<% if GalleryItems %>
<% control GalleryItems %>
<a id="ViewLink-$ID" class="$JSLightWindow"<% if JSMedia %> rel="$JSMedia"<% end_if %> href="$ViewLink" title="$Title">
<img src="$ThumbnailURL" alt="$Title"/>
</a>
<% end_control %>
<% else %>
No Images
<% end_if %>
<% end_control %>

You have to check that all the corresponding JS and CSS files (e. g. for lightbox) are called correctly in you template.
The only thing I'm struggling with so far is the multi language use of this feature...

Avatar
Lamin Barrow

Community Member, 22 Posts

17 December 2009 at 7:44am

Enter this code

$RecentImagesGallery(10)

in any page template file. This will pull the latest 10 images from your image gallery.

Avatar
Lamin Barrow

Community Member, 22 Posts

17 December 2009 at 7:44am

Enter this code

$RecentImagesGallery(10)

in any page template file. This will pull the latest 10 images from your image gallery.