Filter file manager
Permalink
I'm trying to filter the files shown in the file manager, but cannot figure out how. I've searched the forum and found some stuff, but none seems to work.
For example, I want the file manager to show only PDF files. The code I've found passes any array of extensions, but that doesn't work.
Any ideas? Thanks!
For example, I want the file manager to show only PDF files. The code I've found passes any array of extensions, but that doesn't work.
Any ideas? Thanks!
Oh, sorry.... I didn't describe anything at all. I assumed that since it was in "Building with concrete5" that it would be understood.
I'm trying to do it in a block. I can open the file manager, but cannot filter by file type automatically (ie: only show pdf files)
I'm trying to do it in a block. I can open the file manager, but cannot filter by file type automatically (ie: only show pdf files)
<?php echo $al->file('ccm-b-file', 'fID', t('Choose Document'), $bf);?>
just use the file list class:
$fileList = new FileList();
$fileList->filterByExtension('your_extension');
$files = $fileList->get( 20 );
$fileList = new FileList();
$fileList->filterByExtension('your_extension');
$files = $fileList->get( 20 );
Thanks, that'll do it!
Ok, I thought I could piece it together, but apparently not. Anyone got a more integrated example (showing the file manager with this filter in action)?
Thanks!
Thanks!
oh, you're trying to recreate the whole file manager with that? not sure if there's an easy path headed there. are you trying to make that interface available to your users? in that case maybe the document libraries the way to go. it's not too hard to just add pagination and stuff to a list of files... not sure what you're trying to do.
I'm not trying to recreate the file manager, just limit the display to certain file types. File manager = file helper if that helps any.
Example: In a custom block, user clicks "Select File". File manager opens only showing PDF & DOC files to select from.
I recently found how to filter the file help to 1 file type with the following code and am currently testing it:
Example: In a custom block, user clicks "Select File". File manager opens only showing PDF & DOC files to select from.
I recently found how to filter the file help to 1 file type with the following code and am currently testing it:
In /concrete/helpers/concrete/asset_library.php, line 51, it loops through the arrary of extensions provided, but it only seems to take the last parameter passed. Is this a bug or am I doing something wrong? Here's how I'm passing multiple parameters:
you probably want something more like:
array('fExtension'=>array('pdf','doc'))
array('fExtension'=>array('pdf','doc'))
Nope, that didn't work.
Even in asset_library.php, if you hand code the filter, it still only uses the last entered filter.
It does work if you only pass a single parameter though.
Even in asset_library.php, if you hand code the filter, it still only uses the last entered filter.
It does work if you only pass a single parameter though.
what happens if you do it like this?
$fileList = new FileList();
$fileList->filterByExtension('pdf');
$fileList->filterByExtension('doc');
$fileList->filterByExtension('ppt');
$files = $fileList->get( 20 );
$fileList = new FileList();
$fileList->filterByExtension('pdf');
$fileList->filterByExtension('doc');
$fileList->filterByExtension('ppt');
$files = $fileList->get( 20 );
After a lot of searching through the core concrete5 code... this workaround solves the problem
To clarify, you need to set fKeywords to '' or it will add a whole WHERE clause to the SELECT which looks for *.* and %*.*%.
Despite searching for an hour, I couldn't find where fKeywords was being initialised to *.*
To clarify, you need to set fKeywords to '' or it will add a whole WHERE clause to the SELECT which looks for *.* and %*.*%.
Despite searching for an hour, I couldn't find where fKeywords was being initialised to *.*
This worked fine for me so only pdfs get shown:
$al->file('ccm-b-file', 'pdf', t('Choose a pdf'), $pdf, array('fExtension'=>'pdf'));
at mine it does.