By jmunning on
Hi everyone,
I would like to add checkboxes and a submit button to a view. The checkboxes would appear next to each node and then when the submit button was clicked it would pass the info about each checked node (the filename of the attached file) to a php script (which will zip and force the download of all the selected attachments).
Can anyone point me in the right direction? Would this have to do with theming my view?
Thanks!
Comments
Two Options
When I've done this, I've done it without Views (because I was importing from a legacy database) - create a form and then use a theme callback to create the table with the checkboxes, but I think it could be done using Views theming.
If you use the Table style for your view (I'll assume the view name if "listing"), you should be able to copy views-view-table.tpl.php from your modules\views\themes folder and rename it to views-view-table--listing.tpl.php in your theme directory. In there you can control the output of the table to add your checkboxes to each row, add the submit button and the form tags.
It may not be the ideal solution but it should work.
David
Don't have a modules\views\themes folder
Don't seem to have a modules\views\themes folder. Do I need to create a view with the view theme wizard for this to appear?
What file controls the HTML output for a view?
Maybe it is because I am on drupal 5 but I can't find a views-view-table.tpl.php file. I can control the $headers and $rows data that gets sent to the theme in template.php but where can I add form tags to the view?
It is because you're Drupal
It is because you're Drupal 5 and Views 1... you should look at these pages for information on theming views 1 tables:
http://drupal.org/node/128741
and
http://drupal.org/node/42597
You should be able to do something similar but it's not in the .tpl.php file
Another option (although I haven't tested this) is that you might be able to use the Computed Field module to make your checkbox fields and then put the form open/close tags and the submit button in the header/footer of the view.
David
Thanks got it working
Thanks for the help! I was able to get it working by theming the table view in template.php to add the checkboxes and then added the form (and select all javascript) tags in the header and footer of the view like you suggested.
Any chance you can post the
Any chance you can post the code here your developed to get this working? It could help me out.
UPDATE - Found a great module for this use : http://drupal.org/project/views_embed_form
Thanks!
Here is the code I used. I
Here is the code I used. I used this code to insert a checkbox in a column with the header "Download link". Hope it helps!
Thanks for the
Thanks for the reply.
However, if you don't make use of drupal_get_form, you are missing out on the validation and other aspects of the FORM API that drupal provides. If I were you I'd move to that module I commented on above, it's been working great for me.
additional information needed
Your code helped me a lot.
I have my checkboxes and a button (can be a link) "Download selected files".
A fiew files are selected and what happen after that?
Do you use download.php? Can you please explain how you did this?
Sorry, i didn't see your
Sorry, i didn't see your request earlier. Here is the code I used to force the user to download the attachments from the selected nodes as a zip file. I needed to customize it to return the correct file names inside the zipped archive. Also, I used a timestamp to ensure that the name of the zip archive would be different each time.
Just want to say thank you,
Just want to say thank you, it works perfectly and saved a lot of my time
...
You should "invent the wheel" as little as possible. The UI for collecting nodes can be provided by other modules ("Views Bulk Operations" might suit you; "Flag" certainly can). Then you're left to implement only the "meat". (BTW, an interesting possibility is to implement the zipping as a Views page- or style- plugin.)