7912 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » Using Custom Classes in ImageGallery
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 800 Views |
-
Using Custom Classes in ImageGallery

27 May 2009 at 3:40pm
From time to time the idea of adding custom fields to the ImageGallery has come up. As of the latest SVN, you can subclass the ImageGalleryPage object and specify your own classnames. Here's an example I used:
MyImageGalleryPage.php
class MyImageGalleryPage extends ImageGalleryPage
{
protected $itemClass = "MyImageGalleryItem";
protected $albumClass = "MyImageGalleryAlbum";
}class MyImageGalleryPage_Controller extends ImageGalleryPage_Controller
{
}MyImageGalleryAlbum.php
class MyImageGalleryAlbum extends ImageGalleryAlbum
{
static $db = array (
'ExtraAlbumField' => 'Text'
);
public function getCMSFields_forPopup()
{
$f = parent::getCMSFields_forPopup();
$f->push(new TextField('ExtraAlbumField'));
return $f;
}
}MyImageGalleryItem
class MyImageGalleryItem extends ImageGalleryItem
{
static $db = array(
'NewField' => 'Text'
);
public function getCMSFields_forPopup()
{
$f = parent::getCMSFields_forPopup();
$f->push(new TextField('NewField'));
return $f;
}
}Then of course you can create MyImageGalleryPage.ss, and MyImageGalleryPage_album.ss for your templates. Not very well tested, but seems to be working well.
Free at last!
| 800 Views | ||
|
Page:
1
|
Go to Top |
