Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi everybody!
I have a View that shows a table from "Documents" content type, where you have a FileField for document uploading, I need now a checkbox(es) in the first row, or above, that will allow the user to select certian(or all) documents and click on the button "Download all". Is it possible to do something like that with Filefield and Views, or I need some extra module for that?
Thanks in advance
Ivana
Comments
Comment #1
landing CreditAttribution: landing commentedSubscribing
Comment #2
quicksketchIt's not possible through Views or FileField directly. You'd need a module like Views Bulk Operations to create the checkboxes and the submit button, and then you'd need some custom code to provide the action to zip up and download all the files together. It's possible through this combination of modules, but I've never seen it done.
Comment #3
vojvotkinja CreditAttribution: vojvotkinja commentedIn case someone still need this, here is my solution, it's not pretty, but it works.
I had to do some custom scripting. I created this js function in my theme script.js
.view-Document-list you have to replace with you own class (depending on view name), and "sites/all/themes/apetrovic/ajax-request.php" is a path to custom script where you process selected files to zip and force download:
So now all you have to do is to add a link, that will call js function. I put it in my view footer like this:
Cheers
Comment #4
landing CreditAttribution: landing commentedI couldn't get this to work...are you creating the form for a custom module or are you using VBO to create the form? I tried to create a form with VBO, but can't get it to work at all.
Comment #5
quicksketchClosing after lack of activity.
Comment #6
Lan CreditAttribution: Lan commentedHi,
Thanks for the code. I have used it for my site and it works great but there is a problem:when i download a file that doesn't exist , it goes to "404 Page not found" page. How i can make it to say"this file doesn't exist "or have some custom word.
Thanks for your help in advance.
Lan