• Resolved DWsCoreWP

    (@dwscorewp)


    Since my English is only rudimentary, I would like to apologize in advance for having to consult the Google translator.

    Hello.

    It’s been a long time since I used DTX for the first time and then only the “dynamictext” function. After a long time, I have now discovered the new possibilities of DTX and I am still enthusiastic about your work on this plugin.

    But since I’m now building a contact form for the first time in years that includes a “subject selection” using a drop-down, I definitely need your help. Thank you in advance for your support.

    Initial situation:

    The contact form provides the visitor with 5 subject options from which they can select one using the drop-down. So far, so simple.

    Objective:

    In addition – and this is where DTX is used, there are 5 different buttons spread across the website (form action with method=”post”), which refer to the contact form and are intended to pre-select a specific subject in the drop-down.

    My problem:

    I’ve already searched through your knowledge base about “Dynamic Select” and tested various things, but to be honest, due to my lack of English knowledge, I only partially understand what it means and I can’t really get used to the form tag generator clear.

    I tried the code below, but it only created an additional entry in the drop-down selection. I suspect that this is completely wrong and that some shortcode needs to be written into the functions.php, which unfortunately I have next to no idea about.

    Code used for Dynamic Select:

    [dynamic_select* subject placeholder:Please select include_blank dtx_disable_blank "CF7_POST key='subject_name'" "Subject example 1" "Subject example 2" "Subject example 3" "Subject example 4" "Subject example 5"]

    Code used for the Form action button:

    <form action="https://example.com/contactform/" method="post">
    <input type="hidden" name="subject_name" value="Subject example 3">
    <button name="Kontakt" title="Kontakt aufnehmen">Kontakt aufnehmen</button>
    </form>

    It would be great if you could help me here by giving me a functional example of how the code should look correctly and what needs to be written in the functions.php.

    Thanks so much

    Best regards
    Werner

    • This topic was modified 1 month, 2 weeks ago by DWsCoreWP.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    Hallo! I too will use a translator in hopes we can communicate better ??

    Objective:

    In addition – and this is where DTX is used, there are 5 different buttons spread across the website (form action with method=”post”), which refer to the contact form and are intended to pre-select a specific subject in the drop-down.

    What is the source of your options for the drop-down? Another way to ask, where is the data stored on your website that will populate the options for the select form field? Knowing that will help me write the shortcode for you.

    Was ist die Quelle Ihrer Optionen für das Dropdown-Menü? Eine andere M?glichkeit zu fragen: Wo sind die Daten auf Ihrer Website gespeichert, die die Optionen für das Auswahlformularfeld füllen? Wenn ich das wei?, kann ich den Shortcode für Sie schreiben.

    —-

    Otherwise, here are some step-by-step generic instructions:

    Ansonsten hier noch eine allgemeine Schritt-für-Schritt-Anleitung:

    Code to use in the form template:

    In der Formularvorlage zu verwendender Code:

    [dynamic_select* subject placeholder:Please%20select default:CF7_POST%20key%3D%26%2339%3Bsubject_name%26%2339%3B include_blank dtx_disable_blank "dwscorewp_subject_select"]

    You can separately define the placeholder text, the preselected default value, and the options. Now in your theme’s functions.php file or in a Code Snippet, place this code:

    Platzhaltertext, Standardwert und Optionen k?nnen separat definiert werden. Füge nun den folgenden Code in die Datei functions.php deines Themes oder in einen Codeausschnitt ein:

    function dwscorewp_subject_select() {

    // Define my options array
    $options = array(
    'Subject example 1',
    'Subject example 2',
    'Subject example 3',
    'Subject example 4',
    'Subject example 5'
    );

    // Return options as JSON encoded string
    return json_encode($options);
    }
    add_shortcode('dwscorewp_subject_select', 'dwscorewp_subject_select');

    In the code snippets above, we are using the “placeholder” attribute to define the static placeholder text when no option is selected. We are using the “default” attribute with the CF7_POST shortcode to dynamically preselect one of the drop-down’s options. And finally, the value within quotes is the custom shortcode in the second snippet that generates your dynamic options. So now when you visit your website with the query parameter like so: example.com/?subject_name=Subject%20example%201 then you should see that subject line preselected!

    In den obigen Codeausschnitten verwenden wir das Attribut ?placeholder“, um den statischen Platzhaltertext zu definieren, wenn keine Option ausgew?hlt ist. Wir verwenden das Attribut ?default“ mit dem Shortcode CF7_POST, um eine der Dropdown-Optionen dynamisch vorab auszuw?hlen. Und schlie?lich ist der Wert in Anführungszeichen der benutzerdefinierte Shortcode im zweiten Ausschnitt, der Ihre dynamischen Optionen generiert. Wenn Sie jetzt Ihre Website mit dem Abfrageparameter wie diesem aufrufen: example.com/?subject_name=Subject%20example%201, sollten Sie die Betreffzeile vorab ausgew?hlt sehen!

    Hope this helps! ??

    Hoffe, das hilft! ??

    Thread Starter DWsCoreWP

    (@dwscorewp)

    Hello Tessa,

    Please excuse me for only being able to answer you now, as I was out of action for a few days for health reasons.

    Thank you for your detailed answer to my post and also for translating the answers into German for me. I really liked it and thought it was really great of you ??

    Based on your answers and the question about stored data, I must have completely misunderstood the actual application area and current function of DTX. At least as far as my application is concerned.

    To explain:
    When I installed DTX for the first time many years ago, this was because you couldn’t transfer data to a CF7 text field using “Post or GET”. I solved this with DTX at the time.

    And only now, after many years, I was looking for a way to use “Post or GET” to preselect a specific CF7 drop-down select entry.

    What I didn’t know at the time of my post and the email to you, however, was that pure transmission using “Post or GET” has been implemented in CF7 for some time and that DTX is no longer necessary for this function.

    So I’m really terribly sorry if I’ve wasted your time with my request, but I only found this out by chance after my post to you (see the link below), before I got a bout of flu.

    CF7: Getting default values ??from the context
    https://contactform7.com/getting-default-values-from-the-context/

    I think that I may have expressed myself somewhat poorly in my post, so that you had to assume that my request was actually a DTX use case, which is what I assumed myself at first.

    At this point I would like to apologize to you again for not doing more thorough research before my post to you. The idea that CF7 can already do this never occurred to me. I only knew from the past that this was possible with DTX.

    As a small gesture of reparation, I would like to do something for your coffee fund via PayPal, so please let me know how I can do that.

    Thanks again for your support and your plugin, I will definitely come back to it when a use case requires it.

    Best regards
    Werner

    • This reply was modified 1 month ago by DWsCoreWP.
    Plugin Author Tessa (they/them), AuRise Creative

    (@tessawatkinsllc)

    No problem at all! I’m glad you got it sorted for your use case.

    Yes, CF7 introduced the default attribute where possible options include get, post, post_meta, user_login, user_email, user_url, user_first_name, user_last_name, user_nickname, and user_display_name, but this technique requires the source key to be exactly the same as your form tag’s name.

    So while your form tag may look like this:

    [dynamic_hidden subject_name default:get]

    It requires the parameter in the URL to also be subject_name, such as: https://example.com/?subject_name=Subject%20example%201

    While I’m glad to see this functionality make it into the core of Contact Form 7, DTX offers the flexibility for mapping keys to form fields with different names, adding security through obfuscating the value, and compatibility with caching plugins.

    Take care!

    überhaupt kein Problem! Ich bin froh, dass Sie es für Ihren Anwendungsfall gel?st haben.

    Ja, CF7 hat das Standardattribut eingeführt, bei dem m?gliche Optionen get, post, post_meta, user_login, user_email, user_url, user_first_name, user_last_name, user_nickname, und user_display_name sind, aber diese Technik erfordert, dass der Quellschlüssel genau derselbe ist wie der Name Ihres Formulartags.

    Ihr Formulartag kann also so aussehen:

    [dynamic_hidden subject_name default:get]

    Es erfordert, dass der Parameter in der URL auch der Betreffname ist, z. B.: https://example.com/?subject_name=Subject%20example%201

    Obwohl ich froh bin, dass diese Funktionalit?t in den Kern von Contact Form 7 aufgenommen wurde, bietet DTX die Flexibilit?t, Schlüssel Formularfeldern mit unterschiedlichen Namen zuzuordnen, Sicherheit durch Verschleierung des Werts zu erh?hen und Kompatibilit?t mit Plugins zu gew?hrleisten, die zwischenspeichern.

    Passen Sie auf sich auf!

    Forgot to add, if you really want to donate, the url is https://just1voice.com/donate

    Thanks so much! ??

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