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
We've moved the forum!
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
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.
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?
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().
thanks a lot, that did the trick :)
The ability to use custom classes has been added to the ImageGallery. See the post in the DataObjectManager forum.