Tagged: 

Viewing 18 posts - 1 through 18 (of 18 total)
  • Author
    Posts
  • #547152

    Hello,

    I need a feature of the contact form, but I don’t know how to solve it.

    For example, I have a portfolio with name “Portfolo A”, At the single portfolio entry page, I want to add a button, “I want to know more about it”, link to a contact form page. When the client click the button, I hope the form can auto fill out the portfolio name “Portfolio A” at the first line.

    How should I do? Thank you very much!

    #547352

    Hi endnote,

    That will most likely require a lot of customisation and is probably out of scope of theme support, but send us a link to your site and we’ll have a look.

    Best regards,
    Rikard

    #547380

    Hello, Rikard

    Thank you very much. My site is installed on my local computer now.

    I found a plugin about this, but I don’t know weather will it work or not.

    https://wordpress.org/plugins/contact-form-7-dynamic-text-extension/

    Can you take a look at it? Thank you.

    Jiang

    #547533

    Hi,

    If your site is local only it will be difficult for us to help you unfortunately, the only thing I could recommend is to try the plugin out to see if yields the results you are looking for. We would need to access a live site to have a closer look, though we are not familiar with all plugins out there so we might not be of much help to you anyway.

    Thanks,
    Rikard

    #550251

    Hi,

    I have tested it, and worked well.

    While I installed Contact Form 7 plugin, and Dynamic WordPress Contact Form plugin. When I created a new form with Contact Form 7, I can insert a field which accept dynamic content.

    The contact form bundled with enfold theme cannot accept the dynamic content. Is that Contact Form 7 in enfold theme? How can I edit the shortcode of the contact form in the theme?

    Thank you.

    Jiang

    #551556

    Hey!

    In the portfolio item, create a button which links to the contact form url plus a unique query string. Something like this:

    http:/mysite.com/contactpage?portfolio_name=Portfolio%20Title
    

    In the example above, the portfolio_name=Portfolio%20Title is our query string, where “Portfolio%20Title” is the name of the portfolio item. The “%20” is the encoded form of space. Assuming that the contact form’s first input field’s id is “avia_1_1”, we can add something like this in the functions.php file:

    function add_custom_script(){
    ?>
    <script>
    (function($){
    
        var urlQuery;
        var chopquery = function() {
            var match,
                pl     = /\+/g,  // Regex for replacing addition symbol with a space
                search = /([^&=]+)=?([^&]*)/g,
                decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
                query  = window.location.search.substring(1);
    
            urlQuery = {};
            while (match = search.exec(query))
               urlQuery[decode(match[1])] = decode(match[2]);
        }
    
        chopquery();
        $('#avia_1_1').val(urlQuery["portfolio_name"]);
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'add_custom_script');

    The script should populate the first input field with the value of the query string “portfolio_name”.

    Cheers!
    Ismael

    #1107397

    Works great! Thank you!

    #1107423

    That is realy nice – and it could be tranfered easily to cf7 aswell.

    But : is it possible not to have a manually setting but to insert directly the portfolio name from that url where it comes from.
    All Portfolios have on my setting the syntax of: domain-name/portfolio-item/portfolio_name/

    #1107426

    I use it for titles only. Visitors could change the URL manually, e.g. change the name and price of an event. This would noct be the best solution but für titles it works great!

    Hint: I was thinking about adding a php snippet above the form and place the variables fetched via PHP in the javascript code. maybe a solution?!

    • This reply was modified 5 years, 6 months ago by royaltask.
    #1108743

    Hi,

    @Guenni: Using javascript or jQuery, maybe we can loop through the portfolio items and adjust the items’ href attribute value. First, we should extract the portfolio name by splitting the href string in to an array using “/” as the separator.

    // https://www.w3schools.com/jsref/jsref_split.asp

    We can then use the extracted string as the value of the “portfolio_name” parameter, append it to the href attribute value and re-assign it to the corresponding portfolio items. I hope that’s understandable.

    @royaltask: I’m not really sure what you’re trying to do. Could you elaborate a bit?

    Best regards,
    Ismael

    #1108753

    Mainly it will be that way that you want to set the link from a portfolio page ( or product page ).
    As all portfolio pages, have the standard path: domain/portfolio-item/portfolio-name – why add a manual path? Why not directly transfer the portfolio name?

    #1108768

    Hey!


    @Guenni007
    : I imagined manipulating the href attribute of the items inside the portfolio grid element and append the query parameter to it, but I think I misunderstood your question and I actually forgot that that the button is supposed to be added to the single portfolio page.

    In that case, you should get the current portfolio page url using the window.location.href, split the string so that we can extract the actual portfolio name and append it to the href attribute of the Request button. This function might help.

    // https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams

    Regards,
    Ismael

    #1118168

    is it possible to check multiple boxes in the same checkbox list ?
    f.e. if there is a button with “i’m interested in callback and e-mail contact”

    #1118654

    Hi,

    Yes, that should be possible. Try to enable or set the checked attribute to true once the button is clicked. Something like this:

    $('.button-selector').on('click', function() {
         $('.checkbox1, 'checkbox2').attr('checked','checked');
    });
    

    Best regards,
    Ismael

    #1119311

    hm – i mean in this combination – i have altered the code above to :

    function transfer_url_to_subject_field(){
    ?>
    <script>
    (function($){
    
        var urlQuery;
        var chopquery = function() {
            var match,
                pl     = /\+/g,  // Regex for replacing addition symbol with a space
                search = /([^&=]+)=?([^&]*)/g,
                decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
                query  = window.location.search.substring(1);
    
            urlQuery = {};
            while (match = search.exec(query))
               urlQuery[decode(match[1])] = decode(match[2]);
        }
    
        chopquery();
        $('span.checkbox-403').find('input[value="' + urlQuery["trigger"] + '"]').prop("checked", true);
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'transfer_url_to_subject_field');

    and the checkbox 403 has a lot of entries in my form ( see private Content)

    is it possible to have an urlquery with multiple params in the link – and if : check both checkboxes.

    #1119886

    Hi,

    Maybe the URLSearchParams function will help.

    // https://davidwalsh.name/query-string-javascript

    You can replace the current function with that.

    Best regards,
    Ismael

    #1314730

    You’re the man, Ismael — thanks again for another sweet hack! Re your solution in https://kriesi.at/support/topic/auto-fill-out-a-product-title-to-contact-form/#post-551556 is there a way to tweak that to autofill the E-mail Subject field in the “Backend” option for the Contact Form element? I’m looking for a way to pass some information without having to add a field. I mean, I could pass the info to a field and hide the field with css, but if there’s a way to pass it to the Subject field, that’d be cool.

    And furthermore, my client wants the forms to open in popups. I’m using this type of function to make that happen — https://kriesi.at/support/topic/lightbox-for-mailchimp-form/#post-582439 (that code seemed to break my site, so I’m using this version https://socialspeaknetwork.com/lightbox-popup-on-enfold-tutorial/ ) — I got that working so <a class="inline_popup" href="#team-form-popups">contact form</a> works to open the form in a popup, but I can’t figure out how to add your code without breaking the popup — <a class="inline_popup" href="#team-form-popups?team_name=Mark%20Levy">contact form</a> or any variation of that I’ve tried seems to disable the popup. So, if you have any clue for me on that one, that’d be amazing too.

    Thanks so much — I know I’m asking a lot here!

    • This reply was modified 3 years, 4 months ago by sky19er.
    #1316008

    Hi,

    Thanks for the follow up questions.

    autofill the E-mail Subject field in the “Backend” option for the Contact Form element

    We are not really sure what you mean by that. You might be able to use the avf_form_subject filter to adjust the Subject field of the email. Examples:

    // https://kriesi.at/support/topic/email-subject-in-contact-form/#post-1085790
    // https://kriesi.at/support/topic/enfold-contact-form-debugging/#post-1164771

    Please open a new thread if the solution above is not what you are looking for, and create another thread regarding the lightbox issue. We will close this thread for now.

    Best regards,
    Ismael

Viewing 18 posts - 1 through 18 (of 18 total)
  • The topic ‘Auto fill out a product title to contact form?’ is closed to new replies.