Filter by multiple sets

Permalink
Is there a way of filtering multiple filesets with a single file list call, for example, looking in the code and this currently doesn't look possible?

$fs = FileSet::getByID(1, 2);
$fl = new FileList();
$fl->filterBySet($fs);
$fl->sortBy('fsDisplayOrder', 'asc');
$files = $fl->get();

 
nebuleu replied on at Permalink Reply
nebuleu
What about this:
$fs1 = FileSet::getByID(1);
$fs2 = FileSet::getByID(2);
$fl = new FileList();
$fl->filterBySet($fs1);
$fl->filterBySet($fs2);
$fl->sortBy('fsDisplayOrder', 'asc');
$files = $fl->get();


This code list files in the 2 filesets, not the files only in one of them. Maybe this is not what you need.
magpie replied on at Permalink Reply
Just wondering if you have actually tried this approach?
nebuleu replied on at Permalink Reply
nebuleu
Yes, quickly, and this worked for me. But again, this code list only files who are in the two filesets at the same time, I don't know if this is what you expected, maybe I misunderstood.

If you want some tech details:

$fl->filterBySet() takes one fileset ID, and add it to a private array (filteredFileSetIDs).
https://github.com/concrete5/concrete5/blob/master/web/concrete/core...

This array is used to create the query:
https://github.com/concrete5/concrete5/blob/master/web/concrete/core...
magpie replied on at Permalink Reply
I seem to be getting a blank array?
nebuleu replied on at Permalink Reply
nebuleu
Ok so I probably misunderstood. I was thinking that you needed to get the files who are member of the two filesets, excluding files who are member of only one fileset.
magpie replied on at Permalink Reply
Anyone else got any ideas?
JohntheFish replied on at Permalink Reply
JohntheFish
- The list class has a method to extend with raw snippets of SQL, so you could take what is generated for 'AND', then in its place tack on the same query fragment with 'OR'.

- There are a couple of excellent recent forum threads on high performance listing. Use one of those with 'OR'.

- If extreme performance and size of list is not prohibitive, use Magic Data and Uber List.
magpie replied on at Permalink Reply
Hi John, slightly lost there, would you mind showing an example?