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.

Archive

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

One page to many files relationship?


Reply

5 Posts   1782 Views

Avatar
noizy

8 October 2007 at 3:02pm (Last edited: 8 October 2007 3:02pm), Community Member, 25 Posts

I've got a site that currently has a one-to-one page-to-file relationship, created by adding this to my page.ss code; in the Page extends SiteTree...

static $has_one = array(
"Download" => "File",
);

...and in function getCMSFields()...

$fields->addFieldToTab("Root.Content.Download", new FileIFrameField("Download"));

What I want to be able to do is to upload multiple files to the same page. I see some people have had success with one->many image relationships...

http://www.silverstripe.com/general-discussion/flat/5853
http://www.silverstripe.com/general-discussion/flat/1686

Would a similar approach be feasible, using something like a hasmanycomplextablefield? Any suggestions, advice is welcome. Cheers.

Avatar
Sean

8 October 2007 at 5:37pm Forum Moderator, 921 Posts

I don't see why not.

The example in this post looks pretty much like what you're after:
[url]http://www.silverstripe.com/general-discussion/flat/5853[/url]

Could you not make a dropdown for each line item, which points to an asset in the system? Or, are you looking to have a file uploader for each item, so you upload the file on the spot?

Cheers,
Sean

Avatar
noizy

8 October 2007 at 10:08pm Community Member, 25 Posts

"Or, are you looking to have a file uploader for each item, so you upload the file on the spot?"

Yep, that one.

The FileIFrameField gives the exact functionality I require for a single file (ie. I can upload a new file to the system, or select an existing one from the filestore), I just need to duplicate that behaviour multiple times on the same page.

The way I envision it is that when you upload/add the first file, a second FileIFrameField appears upon the first file being attached to that page. ie. you've always got count(submitted FileIFrameFields)+1 on the admin page.

The last post by jam13 on the http://drupal.org/node/155743 thread does look like what I'm after - I just haven't implemented a HasManyComplexTableField before, so was wondering if it was going to do the job for me in this instance. One way to find out, I suppose...

Avatar
jam13

9 October 2007 at 11:52pm 121 Posts

I'd be interested if you come up with a good solution for this. I eventually abandoned it and went for a workaround solution because HasManyComplexTableField wasn't a very practical system for Images (or I imagine files).

Avatar
Daminipo

22 July 2008 at 8:35pm (Last edited: 22 July 2008 8:53pm), Community Member, 14 Posts

>The way I envision it is that when you upload/add the first file, a second FileIFrameField
>appears upon the first file being attached to that page. ie. you've always got count(submitted
>FileIFrameFields)+1 on the admin page.

That's just what I'm searching at the Moment. Hay anyone found the solution to that?
It would be greatly more User friendly if it could act that way.

I got problems using the FileIFrameField on the HasManyComplexTableField realtion. The solution that was shown here: [url]http://www.silverstripe.com/general-discussion/flat/5853[/url]