I've sub-classed ImageGalleryPage so that I can add new field to allow user to specify which album is used to provide a cover image at a higher level (i have many galleries at top level), and I've changed my gallery pages to use MyGalleryPage...
<?php
class MyImageGalleryPage extends ImageGalleryPage
{
static $hide_ancestor = true;
static $db = array (
'CoverAlbum' => "Varchar(255)"
);
public function getCMSFields($cms) {
$f = parent::getCMSFields($cms);
$f->addFieldToTab("Root.Content.Configuration", new TextField('CoverAlbum', 'Album to use for gallery cover image'));
return $f;
}
}
class MyImageGalleryPage_Controller extends ImageGalleryPage_Controller
{
public static $allowed_actions = array (
);
public function init()
{
parent::init();
}
}
?>
All works fine except that where a gallery only has one album the redirect directly to that album is not working. I'm presuming this is handled by this code in ImageGalleryPage
public function index()
{
if($this->SingleAlbumView())
return $this->renderWith(array($this->getModelClass().'_album','Page'));
return $this->renderWith(array('ImageGalleryPage','Page'));
}
Why is this not working still in my sub-classed version?