Closed lhberg closed 4 years ago
Issue-Label Bot is automatically applying the label Type: Bug
to this issue, with a confidence of 0.80. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!
Links: app homepage, dashboard and code for this bot.
Hi @lhberg
The problem was that you were using lowercase for the ID param. The ID of an attachment (post) object is uppercase.
The following would have worked: [each protocols] <a href="{@ID,wp_get_attachment_url}">{@post_title}</a> [/each]
However, I've created a patch to also support lowercase since we support that in most other cases as well.
I've also enhanced attachment support in each loops for cases when you've extended the attachments with a media Pod. In that case you can use the media fields and traversals.
Please test if you want! Patch: #5855
Cheers, Jory
Issue Overview
I have a custom settings page with a file relationship field 'protocols' with multiple files allowed and get the list of the filenames when I loop through, but the files' urls are not returned; instead, it's the url of the post the shortcode is placed on.
Expected Behavior
The loop should return the files' urls (the files are PDFs)
According to my Slack thread with @jimtrue this should work:
Template: https://codepen.io/lhberg/pen/RwRPgvQ Shortcode: [pods name="protocols_archive" template="Protocolarchive"] Pods setup: https://www.screencast.com/t/gGCBUBgm3 and https://www.screencast.com/t/2YsB2wvE5SX[each protocols] <a href="{@id,wp_get_attachment_url}">{@post_title}</a> [/each]
Current Behavior
The loop returns the url of the post where the shortcode is placed on
I tried the same after clearing Pods cache with a fresh Pod with only one field and a fresh template on a fresh post, to no avail
Steps to Reproduce (for bugs)
Sorry, no live example, the site is not yet publicly accessible
1. 2. 3. 4.
Possible Solution
WordPress Environment
Pods Package Export (helpful!)
{"meta":{"version":"2.7.22","build":1602429065},"pods":{"1569":{"id":1569,"name":"protocols_archive","label":"Dokumentenarchiv","description":"","type":"settings","storage":"none","object":"","alias":"","fields":{"protocols":{"id":1570,"name":"protocols","label":"Protokolle Mitgliederversammlung","description":"","help":"","class":"","type":"file","weight":0,"pick_object":"custom-simple","pick_val":"","sister_id":"","required":"0","file_format_type":"multi","file_uploader":"attachment","file_attachment_tab":"upload","file_edit_title":"0","file_show_edit_link":"1","file_linked":"0","file_limit":"0","file_restrict_filesize":"10MB","file_type":"any","file_field_template":"rows","file_add_button":"Add File","file_modal_title":"Attach a file","file_modal_add_button":"Add File","file_wp_gallery_output":"0","file_wp_gallery_link":"post","file_wp_gallery_columns":"1","file_wp_gallery_random_sort":"0","file_wp_gallery_size":"thumbnail","oembed_enabled_providers_hulucom":"0","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"unique":"0","file_allowed_extensions":"pdf"},"statuten_word_original":{"id":1571,"name":"statuten_word_original","label":"Statuten (Word-Original)","description":"","help":"","class":"","type":"file","weight":1,"pick_object":"custom-simple","pick_val":"","sister_id":"","required":"0","unique":"0","file_format_type":"single","file_uploader":"attachment","file_attachment_tab":"upload","file_edit_title":"0","file_show_edit_link":"1","file_linked":"0","file_limit":"0","file_restrict_filesize":"10MB","file_type":"any","file_field_template":"rows","file_add_button":"Add File","file_modal_title":"Attach a file","file_modal_add_button":"Add File","file_wp_gallery_output":"0","file_wp_gallery_link":"post","file_wp_gallery_columns":"1","file_wp_gallery_random_sort":"0","file_wp_gallery_size":"thumbnail","oembed_enabled_providers_hulucom":"0","pick_post_status":["publish"],"admin_only":"0","restrict_role":"0","restrict_capability":"0","hidden":"0","read_only":"0","roles_allowed":["administrator"],"file_allowed_extensions":"pdf"}},"show_in_menu":1,"menu_name":"Dokumentenarchiv","menu_location":"top","ui_style":"settings","menu_position":"0","expirationdate_year":"2020","expirationdate_month":"10","expirationdate_day":"11","expirationdate_hour":"16","expirationdate_minute":"21","expirationdate_formcheck":"true","expirationdate_expiretype":"draft"}},"templates":{"Protocolarchive":{"id":1573,"name":"Protocolarchive","code":"
<span style=\"font-family:'Fedra Sans 2';font-size:20px;font-style:normal;font-weight:600\">Vereinsdokumente für den Vorstand<\/span><\/p>\r\n
<a href=\"{@statuten_wordoriginal}\" target=\"blank\">⇢ Statuten (.docx)<\/u><\/a><\/p>\r\n
<\/p>\r\n
<span style=\"font-family:'Fedra Sans 2';font-size:16px;font-style:normal;font-weight:600\">Protokolle der Mitgliederversammlungen<\/span><\/p>\r\n
\r\n[each protokolle_mitgliederversammlung]\r\n <li class=\"protocols\"><a href=\"{@id,wp_get_attachmenturl}\" target=\"blank\">⇢ {@post_title} (.PDF)<\/u><\/a><\/li>\r\n[\/each]\r\n<\/p>","type":"template","slug":"dokumentenarchiv","options":{"_uabb_version":"1.28.6","_edit_lock":"1602427368:5","_edit_last":"5","swift-performance":"a:1:{s:14:\"include-styles\";a:1:{i:0;s:0:\"\";}}","_expiration-date-status":"saved","admin_only":"","restrict_capability":"","capability_allowed":"","pod_reference":"a:1:{s:3:\"pod\";s:0:\"\";}"}}}}
Workaround or Alternate Solution Until Bug is Addressed
Related Issues and/or PRs