Saltar navegación

[Resuelto] Display the url for an uploaded life

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem: I would like to loop over several posts and display information from each post, including the URL of each file in a repeating file field.

Solution: Set up the View to display the proper posts, then add a wpv-for-each shortcode to loop over the repeating field. Make sure your slugs are matched up inside the wpv-for-each.

[wpv-for-each field="wpcf-upload-document"]<li>[types field="upload-document"][/types]</li>[/wpv-for-each]

Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/functions/#file
https://toolset.com/documentation/user-guides/views-shortcodes/#vf-153482

This support ticket is created hace 6 años. There's a good chance that you are reading advice that it now obsolete.

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.

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)

Etiquetado: ,

Este tema contiene 10 respuestas, tiene 2 mensajes.

Última actualización por AndreG3332 hace 6 años.

Asistido por: Christian Cox.

Autor
Mensajes
#1158893

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?

#1158992

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.

#1162780

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.

#1162999

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?

#1163622
toolset 111218.png

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.

#1163995

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?

#1164609
Submission image 1.png

Sorry about that, Wrong attachment

#1164878

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.

#1165400
Submission image 2.png

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

#1165615

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]
#1168455

My issue is resolved now. Thank you!