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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Single Album in Image Gallery Subclass

Go to End

3 Posts   1326 Views


Community Member, 42 Posts

10 February 2010 at 2:24am

Edited: 10/02/2010 3:04am

Hi everybody,
we're close to finishing our first SilverStripe Project and there's two questions regarding the Image Gallery Module remaining that i just can't get my head around..

1. I'm using a subclass of ImageGalleryPage set up like so

class PhotoAlbumPage extends ImageGalleryPage {

  static $singular_name = 'Fotoalbum Kategorie';
  static $plural_name = 'Fotoalbum Kategorien';
  static $hide_ancestor = 'ImageGalleryPage';
	public static $db = array(
	public static $has_one = array(
	  'CategoryImage' => 'Image'
	static $defaults = array (
		'CoverImageWidth' => '100',
		'CoverImageHeight' => '100',
		'ThumbnailSize' => '75',
		'Square' => '1',
		'NormalSize' => '500',
		'MediaPerPage' => '30',
		'MediaPerLine' => '6',
		'UploadLimit' => '20'
	function getCMSFields() {
		$fields = parent::getCMSFields();
		$fields->addFieldToTab("Root.Content.Kategoriebild", new ImageField('CategoryImage', 'Kategoriebild'));
		return $fields;


class PhotoAlbumPage_Controller extends ImageGalleryPage_Controller {

	public function getPhotoAlbumRootLink() {
		return $this->Parent()->Link();
	public function getPhotoAlbumCategories() {
		return $this->Parent()->Children();


I'm using this because i need a Category Image/Cover for each Album Page. However, I did not subclass Album or Item..

Everything's working fine, the only problem is that if i have a PhotoAlbumPage with one single gallery in it, Silverstripe renders an empty, basic Page Template, instead of (what i believe is the default action for a single gallery page) rendering the gallery directly, bypassing the album list.

Is there a way to control/override this behaviour?

And 2. is there a way yet to paginate the Album List view? I don't think it's officially implemented yet, but are there any working code examples for this?

Many thanks in advance, and good day to all of you,

p.s. I fully agree with other posters on this forum that Uncle Cheese's work with DOM is what makes Silverstripe stand out the most at this point. It's a great module, i really appreciate all the effort you are putting into it. Had to be said : )


I renamed my album template from to, and the single album view worked fine. I had been wondering before why working with the Layout template was not working in some cases, so i ended up having two identical Templates for PhotoAlbumPage and ImageGalleryPage

The problem seems to be in the module, because the ancestor class explicitly defaults to the ImageGalleryPage template if there's more than one album on the page.

Changing line 327 ff. in image_gallery/code/ImageGalleryPage.php to

	public function index()
				return $this->renderWith(array($this->getModelClass().'_album','Page'));
			return $this->renderWith(array($this->getModelClass(),'ImageGalleryPage','Page'));

seems to do the trick. I wonder if that should be rolled in, or am i overlooking something here?


Forum Moderator, 4102 Posts

10 February 2010 at 4:53am

Make sure you have created


Forum Moderator, 4102 Posts

10 February 2010 at 4:55am

Oops.. looks like you've already figured it out.

Yeah, that isn't handled very well. I think what it should really do is something like

return $this->album();

but that action is not actually defined in the controller.

What about $this->getViewer()? Isn't that the way you find a template? I'm getting rusty.