I have a scenario where a consultant would request documents from a client. The clients will then upload the Documents. I now need to create a view that will contain the url of the uploaded document, uploaded via a cred form, so that the consultant can then download the document for perusal.
How do I create such a URL in a view that is clickable to download the documents?
If you use a "file" custom field type, your Users can upload a document via Forms. Then you can use Types field shortcodes to output the file URL or a download link.
https://toolset.com/documentation/customizing-sites-using-php/functions/#file
If the file input field allows multiple instances (a repeating field), you can use the wpv-for-each shortcode to loop over each field and output a list of files.
https://toolset.com/documentation/user-guides/views-shortcodes/#vf-153482
Let me know if you have questions about implementing these shortcodes.
HI Christian
I have tried your solution but i seem to be missing something.
In short, the submission Cpt only has one field and that is the upload field.
Here is the code for the CUstom fields fir submissions cpt
The upload field slug is "upload-document"
The template code for the view is
<td>[wpv-post-title]</td>
<td>[types field="date-first-uploaded"][/types]</td>
<td>[types field="status"][/types]</td>
<td>[wpv-post-title]</td>
<td><ol><ol>[wpv-for-each field="wpcf-upload-document"]<li>[types field="my-field"][/types]</li>[/wpv-for-each]</ol></td>
It gives me a "no Items found Error"
The first three entries I am not too worried about because I know what would be the correct code to use. It is just using the shortcode showing the download url that is my issue.
It gives me a "no Items found Error"
If the View shows "No items found", then it's probably not related to these custom fields. It's most likely a problem with the View configurations, where the post just created by Forms is not included in the results for some reason. How is this View's Query Filter set up? What post type is selected?
Hi Christian
I have made a Screen print of the view and attached it to his post gathering from your question I Do believe the problem is in the query.
Please check your post - the upload I see here looks like a screen print of this Toolset.com forum post. Maybe it was uploaded accidentally? Do you have a different screenshot to share?
Sorry about that, Wrong attachment
I don't see anything obviously wrong in this View's Query Filters. What status are the posts created by the Form? If they are not published, you may need to add a post status Query Filter to this View and specify the post status, otherwise only published posts will be displayed. If the posts are published, then there is something else going on and I'll need to take a closer look.
Hi Christian,
Ok that problem solved. Now to the final issue. when I run the report it shows the value 1 instead of the link of the file to be downloaded.
I did not change the code at all. Screen print attached
It looks like the field slugs in the wpv-for-each shortcode are mismatched:
[wpv-for-each field="wpcf-upload-document"]<li>[types field="my-field"][/types]</li>[/wpv-for-each]
Instead of my-field, you should use probably use the same field slug without the wpcf- prefix - upload-document:
[wpv-for-each field="wpcf-upload-document"]<li>[types field="upload-document"][/types]</li>[/wpv-for-each]
My issue is resolved now. Thank you!