• Resolved kaostc

    (@kaostc)


    I have a pod with a file field that returns the id of the uploaded file.

    I want this field to be shown as a DIVI button that download the file. So I select the pod file field in link property of DIVI button. The problem is that pod fields return the id, not the permalink of the file, so it does not work. It is possible to (kind of) cast the field to return the permalink instead of id?

    Thanks a lot!

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • I would also love some help with this. While I am using GenerateBlocks and its dynamic data, it appears to be the same issue.

    The documentation for the Files field suggests that “By default, Pods will not link to the file URL when displaying.”

    Is there a way to change this default behavior for use with DIVI/Generate Blocks/ Query Loops, and without using templates and short codes?

    Thread Starter kaostc

    (@kaostc)

    Hi @complexe , I found a workaround to use the url of a file in a button module link, I share it in case it suitable for you also:

    1. Creating a text module with the magic tag that Yousef shared above.
    [pods name="project" use_current="1"]
    <span id="enlace-boton">{@doc_principal_proyecto._src}</span>
    [/pods]

    1. Hiding this text module (but using custom CSS, not by module controls, in other case it won’t work)
    2. Creating a code module, with a jQuery snippet that copies the link from the text to the button link:
    <script>
    $(document).ready(function(){
    $("#boton-documento").attr("href", $("#enlace-boton").text())
    });
    </script>
    Plugin Support Paul Clark

    (@pdclark)

    Workarounds like the one posted by @kaostc above are necessary when working with third-party user interfaces such as Divi, GenerateBlocks, Elementor, and others because the authors of those interfaces decide what data gets associated with the menu items.

    Page Builders with user interfaces closely associated to templates

    Because each of those editors closely associates the presented menus with the stylization of their templates, it’s not usually simple to change their behavior unless those developers provide filters.

    Working around by editing after the page renders

    The solution provided works around the challenge by outputting the value from Pods in plain HTML, then using JavaScript to take a value from that custom HTML and attach it to the builder output after the page renders.

    Alternative workarounds

    When an existing template, page builder, plugin, or theme outputs highly customized templates that don’t integrate with custom data structures as intended, workaround almost always involve one of these:

    • Check third-party plugin code or documentation for PHP filters, such as apply_filters() to modify data.
    • Modify HTML output with JavaScript, as above.
    • Modify HTML output with PHP, such as with ob_start() and DOM functions. This is necessary over JavaScript if the content matters for search engines or other non-JavaScript-enabled visitors.

    Attachment ID to URL

    The WordPress function for getting an attachment URL from the attachment ID is wp_get_attachment_url()

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.