Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » [Solved] Single album redirect no working on subclassed page

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 632 Views
  • redactuk
    Avatar
    Community Member
    115 Posts

    [Solved] Single album redirect no working on subclassed page Link to this post

    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?

  • redactuk
    Avatar
    Community Member
    115 Posts

    Re: [Solved] Single album redirect no working on subclassed page Link to this post

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

  • UncleCheese
    Avatar
    4085 Posts

    Re: [Solved] Single album redirect no working on subclassed page Link to this post

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

    Have you created the template MyImageGalleryPage_album.ss?

  • redactuk
    Avatar
    Community Member
    115 Posts

    Re: [Solved] Single album redirect no working on subclassed page Link to this post

    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

    632 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.