• Resolved Goran

    (@hrvan)


    Hi there.
    I’m using HTML Content to add a button to download PDF but now I realized that PDF differs from package to package.
    The code I’m using inside is:
    <div class=”cff_button_div”><i
    class=”fa fa-file-pdf-o”></i> PDF
    </div>
    Link to pdf we use is saved inside ACF field, and I have the package id inside fieldname2. So I can target ACF dependent on that fieldname. Can you help me with the equation? Please 🙂

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @hrvan,

    I’m sorry, but I don’t know what do you mean with ACF field. I don’t understand the structure of your form and fields.

    Best regards.

    Thread Starter Goran

    (@hrvan)

    By ACF I mean advanced custom fields. They are stored in table wp_postmeta. I’m importing a lot of data in this form with them but now I need to find a solution for this button. Any ideas?

    Plugin Author codepeople

    (@codepeople)

    Hello @hrvan,

    If you need pre-fill some fields with data stored in the wp_postemta table, the correct would be use the set of “DS” fields (the “DS” fields are distributed with the Developer and Platinum versions of the plugin, they read their values from external data-sources like a database or CSV file).

    For example, assuming you have a custom field called: my-field, and you want use its value into the form whose id=1

    – First add a new attributed in the forms shortcode passing the id of post:

    [CP_CALCULATED_FIELDS id="1" current_post="123"]

    Note: all attributes defined through the form’s shortcode different to id, are converted in javascript variables with global scope, so, the previous shortcode creates in the page the javascript variable current_post with the post id, in this case the 123

    – Now, insert for example a “Line Text DS” field, select the database as the datasource to use, and enter as the query to populate the field:

    
    SELECT meta_value as value FROM {wpdb.postmeta} WHERE meta_key="my-field" AND post_id=<%current_post%>
    

    and that’s all, the field will be filled with the value entered through the custom field: my-field, read directly from the database.

    Additional details in the following links:

    https://cff.dwbooster.com/documentation#datasource-fields
    https://cff.dwbooster.com/documentation#datasource-fields-settings

    Best regards.

    Thread Starter Goran

    (@hrvan)

    Hello.
    This is how I was using it before for any other occasions. But the thing is this needed to be a button I can click. If I use an Line Text DS for this is it possible it can be clicked?
    I don’t think so…
    Through ACF I’m parsing the link to a PDF like http://www.somewebsite.com/images/somepdf.pdf
    I’m using this on my packages, and I would like to pass this inside CFF.
    If I somehow can trigger Line Text DS over the class or something this wouldn’t be a problem for me to design it latter with css.

    Plugin Author codepeople

    (@codepeople)

    Hello,

    If you are populating a “hidden DS” field with the absolute URL to the PDF file (http://&#8230;), for example, assuming it is the fieldname1 field, the code to enter as the onclick event of the button, would be as simple as:

    
    window.open(jQuery('[id*="fieldname1_"]').val());
    

    I’m sorry, but this question is not related directly with our plugin, it is a general question of javascript. If you need additional help implementing your project I can offer you a custom coding service from my private website:

    https://cff.dwbooster.com/customization

    Best regards.

    Thread Starter Goran

    (@hrvan)

    Thanks indeed!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘HTML Content’ is closed to new replies.