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.

Archive /

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

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

One page to many files relationship?


Go to End


5 Posts   2107 Views

Avatar
noizy

Community Member, 25 Posts

8 October 2007 at 3:02pm

Edited: 08/10/2007 3:02pm

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

Forum Moderator, 922 Posts

8 October 2007 at 5:37pm

I don't see why not.

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

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

Community Member, 25 Posts

8 October 2007 at 10:08pm

"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

121 Posts

9 October 2007 at 11:52pm

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

Community Member, 14 Posts

22 July 2008 at 8:35pm

Edited: 22/07/2008 8:53pm

>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: http://www.silverstripe.com/general-discussion/flat/5853