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.

DataObjectManager Module

Discuss the DataObjectManager module, and the related ImageGallery module.

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

[Solved] Single album redirect no working on subclassed page


Reply

4 Posts   650 Views

Avatar
redactuk

14 July 2010 at 3:38am (Last edited: 15 July 2010 1:54pm), Community Member, 117 Posts

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

15 July 2010 at 3:20am Community Member, 117 Posts

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

Avatar
UncleCheese

15 July 2010 at 11:51am 4085 Posts

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

Have you created the template MyImageGalleryPage_album.ss?

Avatar
redactuk

15 July 2010 at 1:54pm Community Member, 117 Posts

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