List filtered by file type
Permalink Browser Info Environment
Is it possible to modify the plugin to only list certain types of files?
For instance:
I have different types of images, .docs and .pdf in the same set.
How would you be able to only display the .pdf files in that list?
Any ideas?
For instance:
I have different types of images, .docs and .pdf in the same set.
How would you be able to only display the .pdf files in that list?
Any ideas?
Type: | Discussion |
---|---|
Status: | New |
Yeah, figured multiple sets was the easiest way to make it work.
Thanks for the quick reply :)
Thanks for the quick reply :)
I'm trying to modify an add-on (list files from set) and add options to show certain file types (i.e. PDFs, JPGs, etc.) - but it's proving to be challenging for me (a non-programmer). Have you had any luck or received any feedback from others on this issue or know of any way to do this?
I've managed to find out what the file types are, but am lost on how to tell it in my controller which types of files to display based on what CHECK BOXES were selected...
Any help would be appreciated and the different file sets is not a good option for me, so that's why I'm trying to figure this out.
Thanks!
I've managed to find out what the file types are, but am lost on how to tell it in my controller which types of files to display based on what CHECK BOXES were selected...
Any help would be appreciated and the different file sets is not a good option for me, so that's why I'm trying to figure this out.
Thanks!
Not knowing how far you've got with this, it's a little tricky to suggest what to focus on.
For a non-programmer, the changes to the block needed to list checkboxes, store selections and provide the filtering might be pretty tough going. You'd need to use the filelist function filterByType somewhere, but that's perhaps the easiest bit.
When you say using different file sets isn't an option, can you explain why that is?
Another option could be that you create some block templates for the block and do some rough filtering on those to only output files of the type you want. (a bit hacky, but works ok for smaller lists of files where it's not really a performance issue)
For a non-programmer, the changes to the block needed to list checkboxes, store selections and provide the filtering might be pretty tough going. You'd need to use the filelist function filterByType somewhere, but that's perhaps the easiest bit.
When you say using different file sets isn't an option, can you explain why that is?
Another option could be that you create some block templates for the block and do some rough filtering on those to only output files of the type you want. (a bit hacky, but works ok for smaller lists of files where it's not really a performance issue)
Hi,
I've been successful in making this work. Granted, you have to remember I'm not a programer and you should notice that this is far from perfect and probably not using the best practices as a programmer would know them. However, it works for my little project.
I will attach the files in a zip file and if anyone wishes to download them and see what I did to make this work, feel free. Also please feel free to modify and update it with better code as you see fit.
-- I added in 4 different image file types and 3 document file types that one could choose from using checkboxes.
-- I changed the display file size to show in MB, but left the code to show KB if one wishes to switch that just uncomment it in view.php
-- I updated the <a href> that is displayed for the file so that I could add a class onto it to easily target various file-types using my CSS: <a href="<?php echo $url; ?>" title="<?php echo $fv->getFileName(); ?>" class="<?php echo $fv->getExtension(); ?>"> <?php echo $title; ?></a>
-- I modified my database table, btListFilesFromSet and added 7 columns, showGIF, showJPG, showPNG, showTIFF, showPDF, showDOC, showDOCX, showXLS, showXLSX each as tinyint(3) and unsigned.
Regarding your question about why I wish not to use multiple file sets…my dilemma is that I have one file set which should have about 10 PDFs in it, but I also keep JPGs in that file set which pertain to that particular area of the website. I wish to use your add-on to pull in all the PDFs within that File set, but not the JPGs. I don't want to have a File set called 'Filesetname-JPG' or 'Filesetname-PDF' as that would be too cumbersome to maintain and frustrating I think for some users. I know this can't be that difficult to figure out if I've made it this close but not quite the whole way!! :)
Anyway, so I figured that out - not too shabby for a non-programmer, I think. But I know someone else can easily improve on this!
I've been successful in making this work. Granted, you have to remember I'm not a programer and you should notice that this is far from perfect and probably not using the best practices as a programmer would know them. However, it works for my little project.
I will attach the files in a zip file and if anyone wishes to download them and see what I did to make this work, feel free. Also please feel free to modify and update it with better code as you see fit.
-- I added in 4 different image file types and 3 document file types that one could choose from using checkboxes.
-- I changed the display file size to show in MB, but left the code to show KB if one wishes to switch that just uncomment it in view.php
-- I updated the <a href> that is displayed for the file so that I could add a class onto it to easily target various file-types using my CSS: <a href="<?php echo $url; ?>" title="<?php echo $fv->getFileName(); ?>" class="<?php echo $fv->getExtension(); ?>"> <?php echo $title; ?></a>
-- I modified my database table, btListFilesFromSet and added 7 columns, showGIF, showJPG, showPNG, showTIFF, showPDF, showDOC, showDOCX, showXLS, showXLSX each as tinyint(3) and unsigned.
Regarding your question about why I wish not to use multiple file sets…my dilemma is that I have one file set which should have about 10 PDFs in it, but I also keep JPGs in that file set which pertain to that particular area of the website. I wish to use your add-on to pull in all the PDFs within that File set, but not the JPGs. I don't want to have a File set called 'Filesetname-JPG' or 'Filesetname-PDF' as that would be too cumbersome to maintain and frustrating I think for some users. I know this can't be that difficult to figure out if I've made it this close but not quite the whole way!! :)
Anyway, so I figured that out - not too shabby for a non-programmer, I think. But I know someone else can easily improve on this!
Hi Ryan,
imho displaying file sets by filtering the file type is a really good idea. concrete5 is working with file sets, not with folders. Filtering files is absolutely necessary in file manager. Otherwise there is a huge amount of file sets on bigger sites - all at one level...
An example: I built a website for a high school. Every department there has its own user, section at the website and own file sets. After two years there was a huge amount of file sets. Because every department created own file sets (like folders) for PDFs, Images, Images in Slideshows, special file lists...
Normally (for file manager) every department needs one file set and can filter results (by file type, size, added between date X/Y etc.).
For this page the possibility to choose between images and documents would be very helpful. Every department could show a list with all documents and have the images for articles in the same file set. That could reduce the amount of file set at around 50% and could make the life of the site maintainer much easier ;)
Best
Torsten
imho displaying file sets by filtering the file type is a really good idea. concrete5 is working with file sets, not with folders. Filtering files is absolutely necessary in file manager. Otherwise there is a huge amount of file sets on bigger sites - all at one level...
An example: I built a website for a high school. Every department there has its own user, section at the website and own file sets. After two years there was a huge amount of file sets. Because every department created own file sets (like folders) for PDFs, Images, Images in Slideshows, special file lists...
Normally (for file manager) every department needs one file set and can filter results (by file type, size, added between date X/Y etc.).
For this page the possibility to choose between images and documents would be very helpful. Every department could show a list with all documents and have the images for articles in the same file set. That could reduce the amount of file set at around 50% and could make the life of the site maintainer much easier ;)
Best
Torsten
To do filtering, it's really going to be an override/hack of the block's controller.
You could create a block template for it that did some filtering, which wouldn't be that hard to do, but then this isn't going to work properly if you want to show only a number of items.
My suggestions here:
- Create additional file sets, that only include one file type
- Avoid the use of .doc files on the web - remember that they're actually not a good interchange format and it's more 'polite' in a web sense to supply documents as PDFs.
(sorry, I couldn't help mention that!)