Jump to:

10979 Posts in 2722 Topics by 1815 members

All other Modules

SilverStripe Forums » All other Modules » [Solved] modifying ImageGalleryAlbum.php in image gallery

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 1266 Views
  • marcink
    Avatar
    Community Member
    89 Posts

    [Solved] modifying ImageGalleryAlbum.php in image gallery Link to this post

    hi,
    <br ><br >
    <br ><br >i would like to modify the ImageGalleryAlbum.php file.
    <br ><br >what do i have to do when i don't want to touch the original file?
    <br ><br >
    <br ><br >thanks

  • UncleCheese
    Avatar
    4085 Posts

    Re: [Solved] modifying ImageGalleryAlbum.php in image gallery Link to this post

    Very soon I'll be adding member properties $image_class, and $album_class to the ImageGallery module, which will make this a lot easier. For now you'll have to use a DataObjectDecorator for that.

  • marcink
    Avatar
    Community Member
    89 Posts

    Re: [Solved] modifying ImageGalleryAlbum.php in image gallery Link to this post

    i don't get it.
    i made a new DataObjectDecorator

    class DODImageGalleryAlbum extends DataObjectDecorator
    {
       public function FormattedCoverImage()
       {
          if($this->landscape()){
             return $this->CoverImage()->SetWidth($this->ImageGalleryPage()->CoverImageWidth);
          }else{
             return $this->CoverImage()->SetHeight($this->ImageGalleryPage()->CoverImageWidth);
          }
       }
    }

    in my _config.php i added:

    Object::add_extension('ImageGalleryAlbum', 'DODImageGalleryAlbum');

    but it doesn't work. what is wrong?

  • UncleCheese
    Avatar
    4085 Posts

    Re: [Solved] modifying ImageGalleryAlbum.php in image gallery Link to this post

    First, you should use DataObject::add_extension, since ImageGalleryAlbum is a DataObject. Second, I don't know that you can overload methods in a decorator. You'll probably have to call that function something different, like "MyFormattedCoverImage" and call it that way on the template.

    $this->CoverImage() won't work in a decorator, remember. You'll have to use $this->owner->CoverImage().

  • marcink
    Avatar
    Community Member
    89 Posts

    Re: [Solved] modifying ImageGalleryAlbum.php in image gallery Link to this post

    thanks a lot, that did the trick

  • UncleCheese
    Avatar
    4085 Posts

    Re: [Solved] modifying ImageGalleryAlbum.php in image gallery Link to this post

    The ability to use custom classes has been added to the ImageGallery. See the post in the DataObjectManager forum.

    1266 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.