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

[Solved] Single album redirect no working on subclassed page


Go to End


4 Posts   886 Views

Avatar
redactuk

Community Member, 117 Posts

14 July 2010 at 3:38am

Edited: 15/07/2010 1:54pm

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?

Avatar
redactuk

Community Member, 117 Posts

15 July 2010 at 3:20am

Anyone help with this? I'm sure as always it's something obvious I've missed :(

Avatar
UncleCheese

Forum Moderator, 4102 Posts

15 July 2010 at 11:51am

First, please be more specific. What does "not working" mean?

Have you created the template MyImageGalleryPage_album.ss?

Avatar
redactuk

Community Member, 117 Posts

15 July 2010 at 1:54pm

Bleh

Kept overlooking the line

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

as I had it in my head it was using the ModelClass name from the original class not the subclassed version :(

Thanks Cheese