UncleCheese,
I still have a way to go to build with silverstripe. Thank you for your help.
This is how my PressImageGalleryPage.php looks like now:
<?php
class PressImageGalleryPage extends ImageGalleryPage {
public function GalleryItems() {
$items = parent::GalleryItems();
$used_captions = array();
foreach($items as $i) {
if(in_array($i->Caption, $used_captions)) {
$i->destroy();
}
else {
$used_captions[] = $i->Caption;
}
}
return $items;
}
}
class PressImageGalleryPage_Controller extends ImageGalleryPage_Controller {
}
?>
My Press Image Gallery Page doesn't throw errors anymore, however, the <% control GalleryItems %> doesn't return anything (empty). I created a PressImageGalleryPage.ss in image_gallery/templates/Layout with just hello to test, and the page is not parsed and "hello" does not appear.
Alternatively, I seem to have found a solution with jQuery -- in a mere 6 hours of trial and error :(.
Here my markup (in GalleryUI_layout.ss):
<div class="gallery-layout-wrapper">
<% if GalleryItems %>
<ul class="gallery-layout" id="gallery-list">
<% control GalleryItems %>
<li style="list-style: none;" name="$Caption.EscapeXML">$GalleryItem</li>
<% end_control %>
</ul>
<script>
$(document).ready(function() {
$('ul#gallery-list').find('li').each(function(i) {
var t = $(this).attr("name");
if (($('ul#gallery-list').find("li[name="+t+"]").length) > 1) {
if (t!="") {
$('ul#gallery-list').find("li[name="+t+"]").nextUntil("li[name!="+t+"]").css("display", "none");
}
}
});
});
</script>
<% end_if %>
</div>
The little jQuery script looks for li elements with specific captions and hides the li elements with following identical captions. Maybe this little code can help someone.
The idea is to show in the gallery only the first element of an Image Gallery with a given caption, and to hide the other images with the same caption. In the case of a press page, the gallery shows the magazine cover, and hides the subsequent inside pages of the magazine. Once clicked on the cover magazine image, Lightroom or FancyBox (etc) shows the cover image and the inside pages of the magazine in a sequence.