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.

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.

All other Modules /

Discuss all other Modules here.

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

Customizing the Default Array for Image Gallery in the Config


Go to End


3 Posts   1241 Views

Avatar
Andrew Houle

Community Member, 140 Posts

28 October 2009 at 1:52am

I'm trying to alter the defaults in the Image gallery page (ie the album width, height, etc). I would like to do so in the config file so that I can upgrade to future versions easily. I believe I can do this through a DataObjectDecorator, but I'm lost on the exact way to do so, and have found little to no documentation. Here is my code this far...

ImageGalleryDecorator

class ImageGalleryDecorator extends DataObjectDecorator {
  	static $defaults = array (
		'CoverImageWidth' => '140',
		'CoverImageHeight' => '140'
	);
}

_config.php

DataObject::add_extension("ImageGalleryPage","ImageGalleryDecorator");

Could something like this work? Does anyone have any ideas, or can point me in the right direction? Thanks in advance.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

28 October 2009 at 3:10am

Edited: 28/10/2009 3:11am

You don't need a decorator for that.

_config.php

singleton("ImageGalleryPage")->set_stat('defaults',array(
// etc...
));

If you were to use a decorator, though, you would use:

function extraStatics() {
return array (
'defaults' => array(
// etc..
);
)
}

Avatar
Andrew Houle

Community Member, 140 Posts

28 October 2009 at 3:30am

Ah, that worked, thanks!