Skip Navigation

[Resolved] WordPress Media Library manager on file field lists only one button file in view

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 9 replies, has 1 voice.

Last updated by georgiI 1 month, 2 weeks ago.

Assisted by: Minesh.

Author
Posts
#2821827
3.PNG
2.PNG
1.PNG

Hi,
I have a file field(repeatable) and the upload form - WordPress Media Library manager checked.
The file selection button selects multiple files trough the manager, but the view shows only 1 button with dynamic file url name, although all files have been uploaded.

I have them listed as downloadable buttons and simple single fields in the view and the buttons show only one of the uploaded files in the batch, while the single fields show all.

#2821851

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

I would like to know - are you using blocks to display the file field or classic view shortcodes?

Have you tried repeating field block to display you file field. If you can share problem URL and admin access details and tell me what exactly the output you are looking for within what section of your page.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2822031

Christopher Amirian
Supporter

Languages: English (English )

Hi,

Minesh will be available tomorrow. I checked and the login information worked for me. So we will reply back tomorrow.

Thanks.

#2822195

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

The button block is intended to work with the single link and you have repeating field so you will have multiple links.

To display the download button, I've added the "Fields and Text" block and within that I've added the following code:
=> hidden link

[wpv-for-each field="wpcf-teacher-lessons-upload"]
<div class="tb-button" data-toolset-blocks-button="3e35d6c50fa2f5e9a243113d42c47385"><a class="tb-button__link" href="[types field='teacher-lessons-upload' output='raw'][/types]"><i class="tb-button__icon"></i><span class="tb-button__content">Download</span></a></div>

[/wpv-for-each]

You can adjust the code as required and add your desired CSS to change the look and feel of the download button.

Also, you will not be able to show the file name, if you want to display the file name, you will have to use the custom shortcode. Please check the following related ticket:
- https://toolset.com/forums/topic/how-to-display-just-the-file-name-for-a-repeater-field-block-from-a-file-field/

#2822197

i can no longer access the view to edit the code,so my file names are shown. The view just keeps loading and does not load

#2822202

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

What file names you want to display? if you can share information I am happy to check and fix that.

Have you added the custom shortcode and used within your view?

#2822215

I managed to get to the view, but no matter what i do the save button is not clickable and i cannot save any progress.
Like before i need the filename to be visible - not the whole path.
I made it work before, but now it no longer works with the new code.

#2822221

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I would like to know have you try using the custom shortcode to display the file name?

#2822228

yes, the last code working was:

[teacher_lessons_filename]

function toolset_file_field_filename_only() { $url = types_render_field('teacher-lessons-upload', array('output' => 'raw')); if (!$url) return ''; return basename($url); // returns just 'filename.pdf' } add_shortcode('teacher_lessons_filename', 'toolset_file_field_filename_only');

#2822334

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Please check now: hidden link

I've added the following custom shortcode to "Custom Code" section offered by Toolset with the code snippet namely "toolset-cutom-code":
=> hidden link

function toolset_file_field_filename_only($atts, $content = null) {
     $file_url = trim(wpv_do_shortcode($content));

    if (empty($file_url)) {
        return '';
    }

    // Extract and return the file n
    return basename($file_url); // Extracts filename only
}
add_shortcode('teacher_lessons_filename', 'toolset_file_field_filename_only');

And within your view' I've adjusted the code to display button as given under:

[wpv-for-each field="wpcf-teacher-lessons-upload"]
<div class="tb-button" data-toolset-blocks-button="3e35d6c50fa2f5e9a243113d42c47385"><a class="tb-button__link" href="[types field='teacher-lessons-upload' output='raw'][/types]"><i class="tb-button__icon"></i><span class="tb-button__content">[teacher_lessons_filename][types field='teacher-lessons-upload' output='raw'][/types][/teacher_lessons_filename]</span></a></div>
 
[/wpv-for-each]

Can you please confirm it works as expected.

#2822655

Yes, they work now Thank you