Find out which set if any the selected file belongs too

Permalink
Hi all,

I'm trying to figure how to find out which set a file is in once I have the file ID.

Let's say I allow a user to select a picture from the file manager, I need to know which file set, if any, that file belongs to. How would I do that?

I have a sneaking suspicion I will have no choice but to go through manual sql fetching but I'd like to avoid that and use the api instead.

Anyone???

Thank you

mnakalay
 
Gingebean replied on at Permalink Reply
Gingebean
Hi,

yeah I looked for this the other week too ...answer can be found here
http://www.concrete5.org/community/forums/customizing_c5/get-file-s...

For those to lazy to click credits to "PauloCarvalhoDesign"

Loader::model('file_set');
$fs = FileSet::getByID(file_set_id here);
$fsname = $fs->fsName;
<h2>This fileset his called :<?php echo $fsname;?></h2>
mnakalay replied on at Permalink Reply
mnakalay
Hi, Thank you for your answer.
It's not, however what I'm looking for.
You see, in your solution, I can find the name of a fileset knowing its ID.
What I'm trying to find out is the ID of the fileset knowing the ID of a file inside it.

Thanks again for taking the time.
Gingebean replied on at Permalink Reply
Gingebean
ohh yea lol my bad I think there is way with

$sets = $f->getFileSets()

Gets an array containing all FileSet objects in which the current File object appears.

from docs
mnakalay replied on at Permalink Reply
mnakalay
Thanks. I can't believe I actually had a look at that page and didn't see it. Thanks again.
Gingebean replied on at Permalink Reply
Gingebean
no problem mate,
I am going have play arround with it too i think it cud come in very handy if you get it working feel free to share.

Take care
mnakalay replied on at Permalink Reply
mnakalay
Actually what I'm really trying to do is, I think, impossible through the api.

We know that a file can belong to different filesets. When using getFileSets(), I get all the file sets the file belongs too.

What I really want however is to know which fileset the user chose the file from when selecting the file through my add-on. I want to know which fileset exactly.
Gingebean replied on at Permalink Best Answer Reply
Gingebean
hi,
had a little think and maybe you can use javascript
put something like this in the file that is calling the filemanger

$('.group-option').live("click",function(){
curFsId =$(this).attr("id").substr(-1);
alert(curFsId);})


This will get the last selected fileset id from file manager
mnakalay replied on at Permalink Reply
mnakalay
it works. I'll just have to figure out how to get the value from js to php but should be ok.
Thanks again