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.

All other Modules

Discuss all other Modules here.

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

[Solved] modifying ImageGalleryAlbum.php in image gallery


Reply

6 Posts   1278 Views

Avatar
marcink

18 May 2009 at 7:33am (Last edited: 26 May 2009 5:27am), Community Member, 89 Posts

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

Avatar
UncleCheese

18 May 2009 at 8:51am 4085 Posts

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.

Avatar
marcink

25 May 2009 at 5:08am (Last edited: 25 May 2009 5:09am), Community Member, 89 Posts

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?

Avatar
UncleCheese

25 May 2009 at 5:28am (Last edited: 25 May 2009 5:29am), 4085 Posts

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().

Avatar
marcink

26 May 2009 at 5:27am (Last edited: 26 May 2009 5:28am), Community Member, 89 Posts

thanks a lot, that did the trick :)

Avatar
UncleCheese

27 May 2009 at 3:34pm 4085 Posts

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