Problem: I would like to use a JavaScript system to create a zip file that Users can download on the front-end of the site. The zip file generation will be handled by a third-party plugin. I need to be able to loop over repeatable field groups (RFGs) containing file fields so I can push each file into the files array.
Solution: Use jQuery.each to traverse the DOM and find the file URL and filename. Push those items into the zip plugin API. Loop:
<ul> <wpv-loop> <li class="rfg"> <span class="filepath">https://yoursite.com/path/to/image.jpg</span> <span class="filename">File name</span> </li> </wpv-loop> </ul>
JS:
// loop over each result and add the necessary file info to folder jQuery.each('.rfg', function( index, item ){ folder.file( jQuery(item).find('.filepath').text(), jQuery(item).find('.filename').text()); });
Relevant Documentation:
http://api.jquery.com/jquery.each/
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Our next available supporter will start replying to tickets in about 3.30 hours from now. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 2 replies, has 2 voices.
Last updated by 5 years, 8 months ago.
Assisted by: Christian Cox.