FileSet filtering not functioning properly
Permalink
Hi, I am using the following code to create a FileList filteres by FileSet, however the list is also returning those items with no FileSet assigned! Is this correct behaviour or can anyone see something I am doing wrong?
$fs = FileSet::getByName("_Player_".$idContacts); $fl = new FileList(); $fl->filterBySet($fs); $fl->filterByType(FileType::T_IMAGE); $fl->sortByFileSetDisplayOrder(); if ($fl->getTotal() > 0) { $hasphoto = true; $fa = $fl->get(1); $pphoto = $fa[0]; $GLOBALS['playerProfilePhotoID']=$pphoto->getFileID(); } else $hasphoto = false;
Calling filterBySet should only bring in files in the set. But the rest of your code doesn't seem to actually retrieve all of the files but rather only one single file. I'm wondering if you have other code somewhere else that is causing this problem (because if you say "it's returning too many files", I'm not seeing where in your code it's actually returning multiple files -- so there must be some code somewhere else that IS returning multiple files and maybe THAT is the code that's causing the problem).
Thanks for your response,
I've worked out what's happening, the requested fileset doesn't always exist, so when we filter by NULL it returns a list of files with no fileset. The behavious I was expecting was to return no files, but by testing for $fs == NULL we just skip then entire rendering process.
I've worked out what's happening, the requested fileset doesn't always exist, so when we filter by NULL it returns a list of files with no fileset. The behavious I was expecting was to return no files, but by testing for $fs == NULL we just skip then entire rendering process.