Skip Navigation

[Resolved] File upload custom field display from RFG

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a repeatable field group (RFG) that includes a custom file field and a custom text field. I would like to display links to download a the file, but I would like to display the text from the text field in the link instead of the full file path.

Solution: Create a View of the RFG and insert a custom HTML link in the loop:

<a href="[types field='upload-doc' output='raw'][/types]" title="Download [types field='document-name' output='raw'][/types]">[types field='document-name' output='raw'][/types]</a>

Relevant Documentation:
https://toolset.com/course-lesson/creating-and-displaying-repeatable-field-groups/#displaying-repeatable-field-groups

This support ticket is created 2 years, 8 months ago. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. 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 10 replies, has 2 voices.

Last updated by fleurP 2 years, 8 months ago.

Assisted by: Christian Cox.

Author
Posts
#2134389

How can i display file "fiel upload" custom field on a customs post types with only the title name and a download icon as appose to the full file URL.

#2134613
Screenshot-2021-08-05-at-12.35.01.jpg
Screenshot 2021-08-05 at 12.32.13.png

Update on above, managed to display the upload links in content template. I however need the link to not be displayed as URL, butas the doc name that I specify via a custom field. How can I go about this?

#2135161

Hello, so if I understand correctly you have set up a View of this repeatable field group (RFG) that displays a link to each file custom field. Instead of the full URL of each file, you would like to display the text from the Document Name field. Is that correct? You can do that by creating a custom link using the following syntax in a Custom HTML block:

<a href="[types field='file-upload-1' output='raw'][/types]" title="Download [types field='document-name' output='raw'][/types]">[types field='document-name' output='raw'][/types]</a>

Replace file-upload-1 and document-name with the slugs of the file upload 1 and document name fields, respectively. The href of the link will still point to the download file URL, but the text shown will display the Document Name field instead.

Let me know if I've misunderstood what you want to accomplish here.

#2135693

Thanks, I inserted the code as per your suggestion. It however displays blank at the moment.

#2137025

Okay I think I should log in and take a look at how everything is configured in wp-admin, or work with a cloned copy of the site using the Duplicator plugin or the All-in-One WP Migration plugin. I will activate private fields here so you can share login credentials securely. Let me know a URL where I can see the problem in the Content Template.

#2138315
Screen Shot 2021-08-09 at 7.11.18 PM.png

Thanks, I inserted the code as per your suggestion. It however displays blank at the moment.
Maybe you made some changes recently, because I cannot find any View blocks in the Content Template, and the site seems to be missing data in the Repeatable Field Group (RFG).

There is only one custom field group created, and it is the group Document Upload:
hidden link
hidden link
I checked and the slugs of your fields in the RFG are "document-name" and "upload-doc" - see the screenshot here.

The Document Upload field group is only assigned to one post type, the Cinnabar Documents Manager. There is only one published Cinnabar Documents Manager post, and it is here:
hidden link
It has no information in its repeatable field group (RFG). That is the first problem. You should add some information in the RFGs in this post if you want to display them on the front-end of the site.

The second problem is there is no View of RFG in the Content Template that is assigned to this Cinnabar Documents Manager post. The Content Template is here:
hidden link
You should edit the Content Template and insert a View block. Choose the Upload Document RFG in the Content Selection of the View block. Then insert a custom HTML block in the loop of the View and paste the code I provided, but update the file field slug to be 'upload-doc'. The updated code should be:

<a href="[types field='upload-doc' output='raw'][/types]" title="Download [types field='document-name' output='raw'][/types]">[types field='document-name' output='raw'][/types]</a>

Then you should be able to see information from the RFG fields on the front-end of the site.

You can review our lesson on displaying RFG information here: https://toolset.com/course-lesson/creating-and-displaying-repeatable-field-groups/#displaying-repeatable-field-groups

Let me know if this isn't making sense and I can add some content and set up the template further for you.

#2138567
Screenshot 2021-08-10 at 09.03.19.png
Screenshot 2021-08-10 at 09.03.15.png

Thank you for the explanation. I have added the information, but I am not able to add a the RFG (Document Upload). I get the attached popups and cant see where to edit as per the popup instructions.

#2139641
Screen Shot 2021-08-10 at 4.53.04 PM.png
Screen Shot 2021-08-10 at 4.41.54 PM.png
Screen Shot 2021-08-10 at 4.43.37 PM.png

I have added the information, but I am not able to add a the RFG (Document Upload). I get the attached popups and cant see where to edit as per the popup instructions.
Okay two minor problems.
1. In the Content Selection panel of the View block, the "Cinnabar Documents Manager" post type was selected. Instead, I have selected the Upload Document RFG for you, because you want to display entries from the Upload Document RFG in the View results.

2. I also edited the contents of the custom HTML block. I replaced the code there with the code I previously shared with you, and deleted the Fields and Text block for now.

Now on the Cinnabar Documents Manager post, I can see the file download link, "TEST DOWNLOAD".
hidden link

If I click the link, I am redirected to the file field URL as expected:
hidden link

However, that URL shows a server error 500. I'm not sure what is wrong with this PDF file. I found the file in your Media Library here:
hidden link

The URLs of the custom field and the PDF in the Media Library are the same, but for some reason the server will not allow me to view the PDF file at this URL. Perhaps there is some problem with this PDF file, maybe the file is corrupted somehow, or too large or something? I created another item in the RFG as a test and chose a different PDF file from the Media Library. This new link works as expected. The PDF is displayed in the browser. So there must be a problem with that original PDF. I would try choosing a different PDF in the file field, or try uploading a different version of the PDF. The server does not want to display this one for some reason.

#2140289
Screenshot 2021-08-11 at 16.06.23.png

Thank you, that worked. I however have a problem when importing via a CSV that the custom field for the file upload is simple not populated. it imports and creates the actual post, but the file is not populated in the upload field. See attached CSV i'm using to test. Could this be due to the fact that it is a GCF?

The user scenario client adds a title, category and uploads 1 - 10 files which works when done one a one by one basis. We however need to import archived documents. We are using WpAllImports to import the data. How do we import multiple files?

New threads created by Christian Cox and linked to this one are listed below:

https://toolset.com/forums/topic/import-rfg-content-from-csv-file/

#2140413

Importing RFG content from a CSV file is somewhat complicated, because each RFG is treated as a separate custom post in a one-to-many post relationship with its parent post. I have split off a separate ticket so we can discuss this in more detail, since it is a separate topic from displaying custom fields. Let's follow up in the new ticket. I think we can close here if the field display is working now.

#2141821

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.