7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » ImageDataObjectManager: Is it possible to set title on Image?
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: | 1600 Views |
-
ImageDataObjectManager: Is it possible to set title on Image?

5 July 2009 at 5:22am
Hey,
I like this module very much. Great work!
I have an ImageDataObjectManager running smoothly with simple DataObject (just image, parentPage and title). However, I wonder is it possible to work with image object "Title" rather than extra property?I imagine two approaches:
1. use an object extending Image classclass PageImage extends Image
{
static $has_one = array (
'ParentPage' => 'Page'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Title'),
new FileIFrameField('GD')
);
}
}
However this won't satisfy ImageDataObjectManager constructor parameters and has awkward Image field2. use Dataobject and write "Title" to Image object
class PageImage extends DataObject
{
static $has_one = array (
'Photo' => 'Image',
'ParentPage' => 'Page'
);
public function getCMSFields_forPopup()
{
return new FieldSet(
new TextField('Photo.Title'),
new FileIFrameField('Photo')
);
}
}
This seems coherent, however it doesn't work ;)Am i doing something wrong? Any ideas?
Thanks,
-
Re: ImageDataObjectManager: Is it possible to set title on Image?

6 July 2009 at 11:57am Last edited: 6 July 2009 11:59am
It sounds like what you want is to extend the ImageGalleryItem class.
class MyImage extends ImageGalleryItem
{
static $db = array (
'MyField' => 'Text'
);
public function getCMSFields_forPopup();
{
$f = parent::getCMSFields_forPopup();
$f->push(new TextField('Title'));
return $f;
}
}Then you need to create a custom ImageGalleryPage class, too.
class MyImageGalleryPage extends ImageGalleryPage
{
public $itemClass = "MyImage";
}I wouldn't use Title as a custom field, though, because it's already on the Image object associated with ImageGalleryItem.
| 1600 Views | ||
|
Page:
1
|
Go to Top |

