3063 Posts in 864 Topics by 646 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1096 Views |
-
Adding different DataObjects to same ComplexTableField

26 April 2010 at 3:22am Last edited: 26 April 2010 1:37pm
Hi,
I have a portfolio page that I want to add several different pieces of media to it. Media at this point is either an image or a swf file but later could be more than that.
A media attachment always has a title, the piece of media (file) and a thumbnail.
There are also some differences between the pieces of media. For example for a swf file I also need to store a width and height variable to use later in the html to display it.I would like to know how to add these two different media attachments, order them (so a page could display say image, swf, image) and have different fields for different media types?
At the moment I have a ComplexTableField in the portfolio page for adding media attachments. So when I go to add a portfolio page to my site I get a complex table field with an "Add Media Attachment" down the bottom. When you add a media attachment it pops up to add the title, thumbnail and file. Unfortunately I can't figure out how to add these extra fields just for attaching swf files. Does anyone have a good solution?
J
-
Re: Adding different DataObjects to same ComplexTableField

28 April 2010 at 8:25pm
As far as I know this is not supported. If you want to manage two different data objects you'll have to add two complextablefields/dataobject managers. However when fetching them for display you can mix them.
Let's say your porfolio has something like this
...
public static $has_many = array(
"ImageAttachments" => "ImageAttachment",
"MovieAttachments" => "MovieAttachment"
);
...Setup two complextablefields or DOM:s in the cms to manage the content and then write a fetch method, for example:
public function getAttachments() {
$images = $this->ImageAttachments();
$movies = $this->MovieAttachments();
$images->merge($movies);
$images->sort("Title");
return $images;
}This way you'll get a DataObjectSet that contains both the images and the movies and they'll be ordered by title if that's what you want.
| 1096 Views | ||
|
Page:
1
|
Go to Top |

