Provides the ability add a Gallery to any number of page types to provide a gallery of images with captions
SilverStripe 4.x or 5.x
- Able to create a set of GalleryItems that each consist of an image and a caption
- Define which PageTypes these GalleryItems should be added to through extensions configurations
- When a galleryitem is clicked on, a lightbox popup shows with carousel functionality
composer require nzta/gallery
You will need to require in the Requirements::javascript('nzta/gallery: js/gallery.js')
in order to display the gallery out of the box and
have the lightbox functionality.
There is also a Requirements::css('nzta/gallery: css/main.css)
file that can be used to display basic styles for the CarouselModal
.
Once you have the assets being pulled in, you will need to add the gallery to the template, e.g. <% include Gallery %>
You will also need the __galleryData
available globally for the JS to work. You can add the following to your <head>
:
<script>
window.__galleryData = {
items: {$GalleryData}
}
</script>
Now you can add the GalleryExtension
to any page type you want to provide a gallery to, e.g.
Page:
extensions:
- NZTA\Gallery\Extensions\GalleryExtension
This will provide the CMS fields to add gallery images to the page.